Comparing version 0.2.2 to 0.2.3
@@ -436,5 +436,5 @@ /* | ||
var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | ||
var escapableExceptBS = /[\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | ||
var escapableExceptBSLF = /[\"\x00-\x09\x0b\x0c\x0e-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | ||
var needsEscape = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | ||
var needsEscapeExceptBS = /[\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; // like needsEscape but without \\ | ||
var needsEscapeExceptBSLF = /[\"\x00-\x09\x0b\x0c\x0e-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; // like needsEscape but without \\, \n and \r | ||
var meta = | ||
@@ -450,3 +450,3 @@ { // table of character substitutions | ||
}; | ||
var escapableName = /[^a-zA-Z0-9]/; | ||
var needsEscapeName = /[^a-zA-Z0-9]/; | ||
var gap = ''; | ||
@@ -462,3 +462,3 @@ var indent = ' '; | ||
{ | ||
return string.replace(escapable, function (a) | ||
return string.replace(needsEscape, function (a) | ||
{ | ||
@@ -476,4 +476,4 @@ var c = meta[a]; | ||
escapableExceptBS.lastIndex = 0; | ||
var isEscapable = escapableExceptBS.test(string); | ||
needsEscapeExceptBS.lastIndex = 0; | ||
var doEscape = needsEscapeExceptBS.test(string); | ||
@@ -483,3 +483,3 @@ // Check if we can insert this string without quotes | ||
var first = string[0], last = string[string.length-1]; | ||
if (isEscapable || | ||
if (doEscape || | ||
isWhite(first) || | ||
@@ -499,6 +499,7 @@ isDigit(first) || | ||
escapable.lastIndex = 0; | ||
escapableExceptBSLF.lastIndex = 0; | ||
if (!escapableExceptBSLF.test(string)) return mlString(string, gap); | ||
else return '"' + (escapable.test(string) ? quoteReplace(string) : string) + '"'; | ||
needsEscape.lastIndex = 0; | ||
needsEscapeExceptBSLF.lastIndex = 0; | ||
if (!needsEscape.test(string)) return '"' + string + '"'; | ||
else if (!needsEscapeExceptBSLF.test(string)) return mlString(string, gap); | ||
else return '"' + quoteReplace(string) + '"'; | ||
} | ||
@@ -531,7 +532,6 @@ else | ||
if (escapableName.test(name)) | ||
if (needsEscapeName.test(name)) | ||
{ | ||
escapable.lastIndex = 0; | ||
var isEscapable = escapable.test(name); | ||
return '"' + (isEscapable ? quoteReplace(name) : name) + '"'; | ||
needsEscape.lastIndex = 0; | ||
return '"' + (needsEscape.test(name) ? quoteReplace(name) : name) + '"'; | ||
} | ||
@@ -538,0 +538,0 @@ else |
@@ -6,3 +6,3 @@ { | ||
"author": "Christian Zangl", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"tags": [ | ||
@@ -9,0 +9,0 @@ "json", |
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
22870