Skip to content

Commit

Permalink
Merge pull request #20766 from vivebhagat/issue-#20681
Browse files Browse the repository at this point in the history
Added support for single and double quotes
  • Loading branch information
masum-ulu authored Oct 8, 2024
2 parents 59e9c5d + 7ddaf46 commit 89dbcf2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions npm/ng-packs/packages/core/src/lib/utils/string-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, ' ');
}

Expand Down

0 comments on commit 89dbcf2

Please sign in to comment.