Skip to content

Commit

Permalink
Update text-formatter.service.ts
Browse files Browse the repository at this point in the history
Prevent null values
  • Loading branch information
cvillarongace committed Jan 14, 2025
1 parent 3823ecb commit a73d02d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class TextFormatter implements Formatter {

do {
previousValue = decodedValue;
decodedValue = decodedValue.replace(entityRegex, (match) => decodeMap[match] || match);
decodedValue = decodedValue?.replace(entityRegex, (match) => decodeMap[match] || match);
} while (decodedValue !== previousValue); // Repeat until no changes

return decodedValue;
Expand All @@ -75,7 +75,7 @@ export class TextFormatter implements Formatter {
* Decodes HTML special characters.
*/
toInternalFormat(value): string {
const formmatedValue = value.replace(/[<>&"'\u00A0-\uFFFF]/g, (match) => {
const formmatedValue = value?.replace(/[<>&"'\u00A0-\uFFFF]/g, (match) => {
const encoded = this.defaultMap[match];
return encoded !== undefined ? encoded : match;
});
Expand Down

0 comments on commit a73d02d

Please sign in to comment.