Skip to content

Commit b411302

Browse files
committed
fix(web): fix lint errors in HTML entity decoder
- Remove duplicate regex pattern |#39 (subset of #\d+) - Replace global isNaN with Number.isNaN for strict checking - Resolves regexp/no-dupe-disjunctions and unicorn/prefer-number-properties violations
1 parent 1fb20fc commit b411302

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/web/src/utils/decode-html-entities.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const HTML_ENTITIES: Record<string, string> = {
2424
* - Decimal numeric entities: &#123;
2525
* - Hex numeric entities: &#x00EF; &#xAB;
2626
*/
27-
const ENTITY_PATTERN = /&(?:amp|lt|gt|quot|apos|nbsp|#39|#\d+|#x[0-9a-fA-F]+);/g;
27+
const ENTITY_PATTERN = /&(?:amp|lt|gt|quot|apos|nbsp|#\d+|#x[0-9a-fA-F]+);/g;
2828

2929
/**
3030
* Maximum iterations to prevent infinite loops
@@ -63,14 +63,14 @@ export const decodeHtmlEntities = (text: string): string => {
6363
// Handle hex numeric entities: &#x00EF; -> ï
6464
if (match.startsWith("&#x") || match.startsWith("&#X")) {
6565
const codePoint = Number.parseInt(match.slice(3, -1), 16);
66-
if (!isNaN(codePoint)) {
66+
if (!Number.isNaN(codePoint)) {
6767
return String.fromCodePoint(codePoint);
6868
}
6969
}
7070
// Handle decimal numeric entities: &#239; -> ï
7171
if (match.startsWith("&#")) {
7272
const codePoint = Number.parseInt(match.slice(2, -1), 10);
73-
if (!isNaN(codePoint)) {
73+
if (!Number.isNaN(codePoint)) {
7474
return String.fromCodePoint(codePoint);
7575
}
7676
}

0 commit comments

Comments
 (0)