Skip to content

Commit

Permalink
fix(): fix invalid double quotes stripping logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Nov 16, 2020
1 parent 557c7a8 commit 5ca90a1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/compiler/helpers/get-value-or-default.ts
Expand Up @@ -49,19 +49,27 @@ export function getValueOfPath<T = any>(
* concatenate the property path.
* Reference: https://github.com/nestjs/nest-cli/issues/947
*/
if (fragment.startsWith('"')) {
path += fragment.replace('"', '') + '.';
if (fragment.startsWith('"') && fragment.endsWith('"')) {
path = stripDoubleQuotes(fragment);
} else if (fragment.startsWith('"')) {
path += stripDoubleQuotes(fragment) + '.';
isConcatInProgress = true;
continue;
} else if (isConcatInProgress) {
} else if (isConcatInProgress && !fragment.endsWith('"')) {
path += '.';
continue;
} else if (fragment.endsWith('"')) {
path += fragment.replace('"', '');
path += stripDoubleQuotes(fragment);
isConcatInProgress = false;
} else {
path = fragment;
}
propertyValue = propertyValue[path];
path = '';
}
return propertyValue as T;
}

function stripDoubleQuotes(text: string) {
return text.replace(/"/g, '');
}

0 comments on commit 5ca90a1

Please sign in to comment.