Browse Source
Merge pull request #11497 from abpframework/fix/string-utils-replace
add type check in escapeHtmlChars func
pull/11498/head
Bunyamin Coskuner
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
8 additions and
5 deletions
-
npm/ng-packs/packages/core/src/lib/utils/string-utils.ts
|
|
@ -22,9 +22,12 @@ export function interpolate(text: string, params: string[]) { |
|
|
.replace(/\s+/g, ' '); |
|
|
.replace(/\s+/g, ' '); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function escapeHtmlChars(value: string) { |
|
|
export function escapeHtmlChars(value: any) { |
|
|
return ( |
|
|
return value && typeof value === 'string' |
|
|
value && |
|
|
? value |
|
|
value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"') |
|
|
.replace(/&/g, '&') |
|
|
); |
|
|
.replace(/</g, '<') |
|
|
|
|
|
.replace(/>/g, '>') |
|
|
|
|
|
.replace(/"/g, '"') |
|
|
|
|
|
: value; |
|
|
} |
|
|
} |
|
|
|