Browse Source
Added support for single and double quotes
pull/21005/head
Masum ULU
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
4 additions and
2 deletions
-
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, ' '); |
|
|
|
} |
|
|
|
|
|
|
|
|