liquid-json
Advanced tools
Comparing version 0.1.0 to 0.2.0
var bomb = { | ||
/** | ||
* @private | ||
* @type {Object} | ||
*/ | ||
code: { | ||
FEFF: 0xFEFF, | ||
BBBF: 0xBBBF, | ||
FE: 0xFE, | ||
FF: 0xFF, | ||
EF: 0xEF, | ||
BB: 0xBB, | ||
BF: 0xBF | ||
}, | ||
/** | ||
* Checks whether string has BOM | ||
@@ -14,3 +28,3 @@ * @param {String} str | ||
// remove UTF-16 and UTF-32 BOM (https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) | ||
if (str.charCodeAt(0) === 0xFEFF) { | ||
if ((str.charCodeAt(0) === bomb.code.FEFF) || (str.charCodeAt(0) === bomb.code.BBBF)) { | ||
return 1; | ||
@@ -20,3 +34,3 @@ } | ||
// big endian UTF-16 BOM | ||
if ((str.charCodeAt(0) === 0xFE) && (str.charCodeAt(1) === 0xFF)) { | ||
if ((str.charCodeAt(0) === bomb.code.FE) && (str.charCodeAt(1) === bomb.code.FF)) { | ||
return 2; | ||
@@ -26,3 +40,3 @@ } | ||
// little endian UTF-16 BOM | ||
if ((str.charCodeAt(0) === 0xFF) && (str.charCodeAt(1) === 0xFE)) { | ||
if ((str.charCodeAt(0) === bomb.code.FF) && (str.charCodeAt(1) === bomb.code.FE)) { | ||
return 2; | ||
@@ -32,4 +46,4 @@ } | ||
// UTF-8 BOM | ||
if ((str.charCodeAt(0) === 0xEF) && (str.charCodeAt(1) === 0xBB) && | ||
(str.charCodeAt(2) === 0xBF)) { | ||
if ((str.charCodeAt(0) === bomb.code.EF) && (str.charCodeAt(1) === bomb.code.BB) && | ||
(str.charCodeAt(2) === bomb.code.BF)) { | ||
return 3; | ||
@@ -36,0 +50,0 @@ } |
{ | ||
"name": "liquid-json", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Implementation of JSON that ignores BOM and thows friendly error", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
47045
842