Browse Source

Merge pull request #20766 from vivebhagat/issue-#20681

Added support for single and double quotes
pull/21005/head
Masum ULU 1 year ago
committed by GitHub
parent
commit
89dbcf21d8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      npm/ng-packs/packages/core/src/lib/utils/string-utils.ts

6
npm/ng-packs/packages/core/src/lib/utils/string-utils.ts

@ -17,8 +17,10 @@ export function createTokenParser(format: string) {
}
export function interpolate(text: string, params: string[]) {
return text
.replace(/(['"]?\{\s*(\d+)\s*\}['"]?)/g, (_, match, digit) => params[digit] ?? match)
return text
.replace(/(['"])?\{\s*(\d+)\s*\}\1/g, (_, quote, digit) =>
(quote ? quote : '') + (params[digit] ?? `{${digit}}`) + (quote ? quote : '')
)
.replace(/\s+/g, ' ');
}

Loading…
Cancel
Save