Skip to content

Commit 8d4313b

Browse files
author
Simon he
committed
chore: add escaoeHtml
1 parent 3e5840f commit 8d4313b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/escapeHtml.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function escapeHtml(s: string): string {
2+
return s.replace(/[&<>'"]/g, tag => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '\'': '&#39;', '"': '&quot;' }[tag] || tag))
3+
}

0 commit comments

Comments
 (0)