1.0.2 • Published 7 years ago

workplus-escape v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

workplus-escape npm

Toggle escape string and object for use in HTML.

Install

npm install --save workplus-escape

Usage

import { 
    escapeString,
    unescapeString,
    escapeObject,
    unescapeObject 
} from 'workplus-query-string';

const str = escapeString('<h1></h1>"');
// str => '&lt;h1&gt;&lt;/h1&gt;&quot;'

const rts = unescapeString('&lt;h2&gt;&lt;/h2&gt;');
// rts => '<h2></h2>'

let someObject = {
    a: '<h1></h1>',
    b: "'",
    c: {
        x: '""'
    }
};
let obj = escapeObject(someObject);
// obj.a => '&lt;h1&gt;&lt;/h1&gt;'
// ibj.b => '&#39;'
// obj.c.x => '&quot;&quot;'

let jbo = unescapeObject(obj);
// jbo.a => '<h1></h1>'

Why not use "&apos;"

Development

git clone https://github.com/WorkPlusFE/workplus-escape.git

npm install

npm test

License

MIT