html.ts
This file
Path
src/utils/html.ts
13 lines · 383 bytes · TypeScript
Last changed by
refactor(html): make `html` as middleware (#319)Yusuke Wadabefore adoption5976a60
History of this fileTake it
feat: Introduce html template literals tag. (#312)Taku Amanobefore adoption9488e33
lines 1–2why, one step back1export type HtmlEscapedString = string & { isEscaped: true }2Merge pull request #306 from honojs/feat/jsxYusuke Wadabefore adoption583d3d4
lines 3–12why, one step back3const entityMap: Record<string, string> = {4 '&': '&',5 '<': '<',6 '>': '>',7 '"': '"',8}9const escapeRe = new RegExp(`[${Object.keys(entityMap).join('')}]`, 'g')10const replaceFn = (m: string) => entityMap[m]11export const escape = (str: string): string => {12 return str.replace(escapeRe, replaceFn)feat: Introduce html template literals tag. (#312)Taku Amanobefore adoption9488e33
line 13why, one step back13}