Comparing version 0.0.6 to 0.0.7
@@ -0,1 +1,2 @@ | ||
var punycode = require('punycode'); | ||
var entities = require('./entities.json'); | ||
@@ -40,6 +41,6 @@ | ||
.replace(/&#(\d+);?/g, function (_, code) { | ||
return String.fromCharCode(code); | ||
return punycode.ucs2.encode([code]); | ||
}) | ||
.replace(/&#[xX]([A-Fa-f0-9]+);?/g, function (_, hex) { | ||
return String.fromCharCode(parseInt(hex, 16)); | ||
return punycode.ucs2.encode([parseInt(hex, 16)]); | ||
}) | ||
@@ -53,3 +54,3 @@ .replace(/&([^;\W]+;?)/g, function (m, e) { | ||
if (typeof target === 'number') { | ||
return String.fromCharCode(target); | ||
return punycode.ucs2.encode([target]); | ||
} | ||
@@ -56,0 +57,0 @@ else if (typeof target === 'string') { |
{ | ||
"name" : "ent", | ||
"description" : "Encode and decode HTML entities", | ||
"version" : "0.0.6", | ||
"version" : "0.0.7", | ||
"repository" : "https://github.com/substack/node-ent.git", | ||
@@ -31,5 +31,5 @@ "author" : "James Halliday <mail@substack.net> (http://substack.net)", | ||
"devDependencies" : { | ||
"tap" : "~0.3.3", | ||
"tape" : "~0.1.0" | ||
"tap" : "~0.4.3", | ||
"tape" : "~1.0.4" | ||
} | ||
} |
var test = require('tape'); | ||
var punycode = require('punycode'); | ||
var ent = require('../'); | ||
@@ -61,1 +62,9 @@ | ||
}); | ||
test('astral num', function (t) { | ||
var a = punycode.ucs2.encode([0x1d306]); | ||
var b = '𝌆'; | ||
t.equal(ent.decode(b), a); | ||
t.equal(ent.decode(b + b), a + a); | ||
t.end(); | ||
}); |
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
11371
374