changed replace to global replace

This commit is contained in:
lotte
2021-03-31 13:51:40 +02:00
parent 0488cd6b45
commit 7afcebfd11
2 changed files with 3 additions and 2 deletions

View File

@@ -32,7 +32,8 @@ const multiMap = {
}; };
const regexTestMap = { const regexTestMap = {
'foolbar.baz': [test] 'foolbar.baz': [test],
'foo.bard': [test],
}; };
const multiViewModelList = [ const multiViewModelList = [

View File

@@ -156,7 +156,7 @@ export class Metadata {
const outputKeys: string[] = []; const outputKeys: string[] = [];
for (const inputKey of inputKeys) { for (const inputKey of inputKeys) {
if (inputKey.includes('*')) { if (inputKey.includes('*')) {
const inputKeyRegex = new RegExp('^' + inputKey.replace('.', '\\.').replace('*', '.*') + '$'); const inputKeyRegex = new RegExp('^' + inputKey.replace(/\./g, '\\.').replace('*', '.*') + '$');
for (const mapKey of Object.keys(mdMap)) { for (const mapKey of Object.keys(mdMap)) {
if (!outputKeys.includes(mapKey) && inputKeyRegex.test(mapKey)) { if (!outputKeys.includes(mapKey) && inputKeyRegex.test(mapKey)) {
outputKeys.push(mapKey); outputKeys.push(mapKey);