Socket
Socket
Sign inDemoInstall

ent

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ent - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

12

index.js

@@ -16,14 +16,18 @@ var punycode = require('punycode');

var numeric = true;
if (opts.named) numeric = false;
if (opts.numeric !== undefined) numeric = opts.numeric;
return str.split('').map(function (c) {
var cc = c.charCodeAt(0);
var e = revEntities[cc];
if (e && (cc >= 127 || special[c]) && !opts.numeric) {
if (e && (cc >= 127 || special[c]) && !numeric) {
return '&' + (e.match(/;$/) ? e : e + ';');
}
else if (cc < 32 || cc >= 127 || special[c]) {
return '&#' + cc + ';';
}
else if (/\s/.test(c)) {
return c;
}
else if (cc < 32 || cc >= 127 || special[c]) {
return '&#' + cc + ';';
}
else {

@@ -30,0 +34,0 @@ return c;

{
"name" : "ent",
"description" : "Encode and decode HTML entities",
"version" : "1.0.0",
"version" : "2.0.0",
"repository" : "https://github.com/substack/node-ent.git",

@@ -6,0 +6,0 @@ "author" : "James Halliday <mail@substack.net> (http://substack.net)",

@@ -7,3 +7,3 @@ var test = require('tape');

var a = 'a & b & c';
var b = 'a &amp; b &amp; c';
var b = 'a &#38; b &#38; c';
t.equal(ent.encode(a), b);

@@ -16,3 +16,3 @@ t.equal(ent.decode(b), a);

var a = '<html> © π " \'';
var b = '&lt;html&gt; &copy; &pi; &quot; &apos;';
var b = '&#60;html&#62; &#169; &#960; &#34; &#39;';
t.equal(ent.encode(a), b);

@@ -23,5 +23,13 @@ t.equal(ent.decode(b), a);

test('html named', function (t) {
var a = '<html> © π " \'';
var b = '&lt;html&gt; &copy; &pi; &quot; &apos;';
t.equal(ent.encode(a, { named: true }), b);
t.equal(ent.decode(b), a);
t.end();
});
test('entities', function (t) {
var a = '\u2124';
var b = '&Zopf;';
var b = '&#8484;';
t.equal(ent.encode(a), b);

@@ -32,2 +40,10 @@ t.equal(ent.decode(b), a);

test('entities named', function (t) {
var a = '\u2124';
var b = '&Zopf;';
t.equal(ent.encode(a, { named: true }), b);
t.equal(ent.decode(b), a);
t.end();
});
test('num', function (t) {

@@ -34,0 +50,0 @@ var a = String.fromCharCode(1337);

@@ -10,5 +10,5 @@ var test = require('tape');

t.equal(ent.encode(a, { numeric: true }), ax);
t.equal(ent.encode(b, { numeric: true }), bx);
t.equal(ent.encode(a), ax);
t.equal(ent.encode(b), bx);
t.end();
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc