JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7934665
  • Score
    100M100P100Q218886F
  • License MIT

Escape a string for use in HTML or the inverse

Package Exports

  • escape-goat

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (escape-goat) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

escape-goat

Escape a string for use in HTML or the inverse

Build Status

Install

$ npm install escape-goat

Usage

const escapeGoat = require('escape-goat');

escapeGoat.escape('🦄 & 🐐');
//=> '🦄 & 🐐'

escapeGoat.unescape('🦄 & 🐐');
//=> '🦄 & 🐐'

escapeGoat.escape('Hello <em>World</em>');
//=> 'Hello &lt;em&gt;World&lt;/em&gt;'

API

escapeGoat.escape(input)

Escapes the following characters in the given input string: & < > " '

escapeGoat.unescape(html)

Unescapes the following HTML entities in the given input string: &amp; &lt; &gt; &quot; &#39;

Tip

Ensure you always quote your HTML attributes to prevent possible XSS.

FAQ

Why yet another HTML escaping package?

I couldn't find one I liked that was tiny, well-tested, and had both .escape() and .unescape().

License

MIT © Sindre Sorhus