source:
node_modules/es-toolkit/dist/string/escape.mjs
| Last change on this file was a762898, checked in by , 5 months ago | |
|---|---|
|
|
| File size: 224 bytes | |
| Rev | Line | |
|---|---|---|
| [a762898] | 1 | const htmlEscapes = { |
| 2 | '&': '&', | |
| 3 | '<': '<', | |
| 4 | '>': '>', | |
| 5 | '"': '"', | |
| 6 | "'": ''', | |
| 7 | }; | |
| 8 | function escape(str) { | |
| 9 | return str.replace(/[&<>"']/g, match => htmlEscapes[match]); | |
| 10 | } | |
| 11 | ||
| 12 | export { escape }; |
Note:
See TracBrowser
for help on using the repository browser.
