diff --git a/src/system/string.ts b/src/system/string.ts index a74e7cb..447e118 100644 --- a/src/system/string.ts +++ b/src/system/string.ts @@ -62,8 +62,8 @@ export namespace Strings { const driveLetterNormalizeRegex = /(?<=^\/?)([A-Z])(?=:\/)/; const pathNormalizeRegex = /\\/g; const pathStripTrailingSlashRegex = /\/$/g; - const tokenRegex = /\$\{(\W*)?([^|]*?)(?:\|(\d+)(-|\?)?)?(\W*)?\}/g; - const tokenSanitizeRegex = /\$\{(?:\W*)?(\w*?)(?:[\W\d]*)\}/g; + const tokenRegex = /\$\{(".*?"|\W*)?([^|]*?)(?:\|(\d+)(-|\?)?)?(".*?"|\W*)?\}/g; + const tokenSanitizeRegex = /\$\{(?:".*?"|\W*)?(\w*?)(?:".*?"|[\W\d]*)\}/g; // eslint-disable-next-line no-template-curly-in-string const tokenSanitizeReplacement = '$${this.$1}'; @@ -89,7 +89,10 @@ export namespace Strings { options: { collapseWhitespace: option === '?', padDirection: option === '-' ? 'left' : 'right', - prefix: prefix, + prefix: + prefix?.length > 1 && prefix?.startsWith('"') && prefix?.endsWith('"') + ? prefix.substr(1, prefix.length - 2) + : prefix, suffix: suffix, truncateTo: truncateTo == null ? undefined : parseInt(truncateTo, 10) }