Commits
Tim Donohue authored and github-actions[bot] committed bb84d86cf52
156 156 | * Gets the list of keys in the map limited by, and in the order given by `keyOrKeys`. |
157 157 | * |
158 158 | * @param {MetadataMapInterface} mdMap The source map. |
159 159 | * @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see above. |
160 160 | */ |
161 161 | private static resolveKeys(mdMap: MetadataMapInterface = {}, keyOrKeys: string | string[]): string[] { |
162 162 | const inputKeys: string[] = keyOrKeys instanceof Array ? keyOrKeys : [keyOrKeys]; |
163 163 | const outputKeys: string[] = []; |
164 164 | for (const inputKey of inputKeys) { |
165 165 | if (inputKey.includes('*')) { |
166 - | const inputKeyRegex = new RegExp('^' + inputKey.replace(/\./g, '\\.').replace(/\*/g, '.*') + '$'); |
166 + | const inputKeyRegex = new RegExp('^' + inputKey.replace(/\\/g, '\\\\').replace(/\./g, '\\.').replace(/\*/g, '.*') + '$'); |
167 167 | for (const mapKey of Object.keys(mdMap)) { |
168 168 | if (!outputKeys.includes(mapKey) && inputKeyRegex.test(mapKey)) { |
169 169 | outputKeys.push(mapKey); |
170 170 | } |
171 171 | } |
172 172 | } else if (mdMap.hasOwnProperty(inputKey) && !outputKeys.includes(inputKey)) { |
173 173 | outputKeys.push(inputKey); |
174 174 | } |
175 175 | } |
176 176 | return outputKeys; |