diff options
Diffstat (limited to 'web/src/util.js')
| -rw-r--r-- | web/src/util.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/web/src/util.js b/web/src/util.js new file mode 100644 index 0000000..65c718b --- /dev/null +++ b/web/src/util.js @@ -0,0 +1,5 @@ +const ESCAPES = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; + +export function escapeHtml(str) { + return str.replace(/[&<>"']/g, c => ESCAPES[c]); +} |