Socket
Socket
Sign inDemoInstall

ent

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 1.0.0

test/hex.js

14

index.js

@@ -5,6 +5,12 @@ var punycode = require('punycode');

exports.encode = function (str) {
exports.encode = function (str, opts) {
if (typeof str !== 'string') {
throw new TypeError('Expected a String');
}
var special = {
'"': true, "'": true,
'<': true, '>': true,
'&': true
};
if (!opts) opts = {};

@@ -14,9 +20,9 @@ return str.split('').map(function (c) {

var e = revEntities[cc];
if (e) {
if (e && (cc >= 127 || special[c]) && !opts.numeric) {
return '&' + (e.match(/;$/) ? e : e + ';');
}
else if (c.match(/\s/)) {
else if (/\s/.test(c)) {
return c;
}
else if (cc < 32 || cc >= 127) {
else if (cc < 32 || cc >= 127 || special[c]) {
return '&#' + cc + ';';

@@ -23,0 +29,0 @@ }

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

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

"scripts" : {
"test" : "tap test/*.js",
"test" : "tape test/*.js",
"prepublish" : "node build/index.js"

@@ -24,14 +24,13 @@ },

"files" : "test/*.js",
"browsers" : {
"ie" : [ 6, 7, 8, 9 ],
"ff" : [ 3.5, 10, 15.0 ],
"chrome" : [ 10, 22 ],
"safari" : [ 5.1 ],
"opera" : [ 12 ]
}
"browsers" : [
"ie/6..latest",
"ff/3.5", "ff/latest",
"chrome/10", "chrome/latest",
"safari/latest",
"opera/latest"
]
},
"devDependencies" : {
"tap" : "~0.4.3",
"tape" : "~1.0.4"
"tape" : "~2.3.2"
}
}

@@ -40,33 +40,2 @@ var test = require('tape');

test('hex', function (t) {
for (var i = 0; i < 32; i++) {
var a = String.fromCharCode(i);
if (a.match(/\s/)) {
t.equal(ent.decode(a), a);
}
else {
var b = '&#x' + i.toString(16) + ';';
t.equal(ent.decode(b), a);
t.equal(ent.encode(a), '&#' + i + ';');
}
}
for (var i = 127; i < 2000; i++) {
var a = String.fromCharCode(i);
var b = '&#x' + i.toString(16) + ';';
var c = '&#X' + i.toString(16) + ';';
t.equal(ent.decode(b), a);
t.equal(ent.decode(c), a);
var encoded = ent.encode(a);
var encoded2 = ent.encode(a + a);
if (!encoded.match(/^&\w+;/)) {
t.equal(encoded, '&#' + i + ';');
t.equal(encoded2, '&#' + i + ';&#' + i + ';');
}
}
t.end();
});
test('astral num', function (t) {

@@ -73,0 +42,0 @@ var a = punycode.ucs2.encode([0x1d306]);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc