escape-goat
Advanced tools
Comparing version 1.1.0 to 1.2.0
18
index.js
@@ -16,1 +16,19 @@ 'use strict'; | ||
.replace(/>/g, '>'); | ||
exports.escapeTag = function (input) { | ||
const values = [].slice.call(arguments, 1); | ||
let output = input[0]; | ||
for (let i = 0; i < values.length; i++) { | ||
output = output + exports.escape(values[i]) + input[i + 1]; | ||
} | ||
return output; | ||
}; | ||
exports.unescapeTag = function (input) { | ||
const values = [].slice.call(arguments, 1); | ||
let output = input[0]; | ||
for (let i = 0; i < values.length; i++) { | ||
output = output + exports.unescape(values[i]) + input[i + 1]; | ||
} | ||
return output; | ||
}; |
{ | ||
"name": "escape-goat", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Escape a string for use in HTML or the inverse", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -30,2 +30,6 @@ <h1> | ||
//=> 'Hello <em>World</em>' | ||
const url = 'https://sindresorhus.com?x="🦄"'; | ||
escapeGoat.escapeTag`<a href="${url}">Unicorn</a>`; | ||
//=> '<a href="https://sindresorhus.com?x="🦄"">Unicorn</a>' | ||
``` | ||
@@ -40,7 +44,14 @@ | ||
### escapeGoat.unescape(html) | ||
### escapeGoat.unescape(input) | ||
Unescapes the following HTML entities in the given `input` string: `&` `<` `>` `"` `'` | ||
### escapeGoat.escapeTag | ||
[Tagged template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals) that escapes interpolated values. | ||
### escapeGoat.unescapeTag | ||
[Tagged template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals) that unescapes interpolated values. | ||
## Tip | ||
@@ -47,0 +58,0 @@ |
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
4398
29
70