Skip to content

Commit e417ae7

Browse files
committed
fix(scripts): decode html entities in audit evidence
1 parent 1c1772e commit e417ae7

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/scripts/src/seo-audit-report.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,17 @@ function parseAttributes(tag: string): Record<string, string> {
152152
return attrs;
153153
}
154154

155+
// Decode common entities instead of blanking them: erasing "&amp;" from
156+
// titles previously produced false findings like a "missing &" typo.
155157
function stripTags(html: string): string {
156158
return html
157159
.replace(/<[^>]+>/g, " ")
160+
.replace(/&amp;/gi, "&")
161+
.replace(/&lt;/gi, "<")
162+
.replace(/&gt;/gi, ">")
163+
.replace(/&quot;/gi, '"')
164+
.replace(/&(?:#x27|#39|apos);/gi, "'")
165+
.replace(/&(?:nbsp|#160);/gi, " ")
158166
.replace(/&[a-z#0-9]+;/gi, " ")
159167
.replace(/\s+/g, " ")
160168
.trim();

0 commit comments

Comments
 (0)