escape-goat
Advanced tools
Comparing version 1.0.1 to 1.1.0
32
index.js
'use strict'; | ||
const escapes = new Map([ | ||
['&', '&'], | ||
['<', '<'], | ||
['>', '>'], | ||
['"', '"'], | ||
['\'', '''] | ||
]); | ||
exports.escape = input => input | ||
.replace(/&/g, '&') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, ''') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>'); | ||
const unescapes = new Map([ | ||
['&', '&'], | ||
['<', '<'], | ||
['>', '>'], | ||
['"', '"'], | ||
[''', '\''] | ||
]); | ||
exports.escape = input => | ||
input.replace(/[&<>"']/g, m => escapes.get(m) || m); | ||
exports.unescape = input => | ||
input.replace(/&(?:amp|lt|gt|quot|#39);/g, m => unescapes.get(m) || m); | ||
exports.unescape = input => input | ||
.replace(/&/g, '&') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, '\'') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>'); |
{ | ||
"name": "escape-goat", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Escape a string for use in HTML or the inverse", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3355
13