Browse Source

Adds support for quoted prefix/suffix in tokens

main
Eric Amodio 5 years ago
parent
commit
9044982bc4
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      src/system/string.ts

+ 6
- 3
src/system/string.ts View File

@ -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)
}

Loading…
Cancel
Save