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
parent
commit
86911b91fa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      npm/ng-packs/packages/core/src/lib/utils/string-utils.ts

13
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, ' ');
}
export function escapeHtmlChars(value: string) {
return (
value &&
value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
);
export function escapeHtmlChars(value: any) {
return value && typeof value === 'string'
? value
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
: value;
}

Loading…
Cancel
Save