Comparing version 1.0.4 to 1.0.5
34
ini.js
@@ -59,6 +59,3 @@ | ||
lines.forEach(function (line, _, __) { | ||
//line = line | ||
var rem = line.indexOf(";") | ||
if (rem !== -1) line = line.substr(0, rem)//.trim() | ||
if (!line) return | ||
if (!line || line.match(/^\s*;/)) return | ||
var match = line.match(re) | ||
@@ -112,11 +109,36 @@ if (!match) return | ||
&& val.slice(-1) === "\"") | ||
|| val !== val.trim() ) ? JSON.stringify(val) : val | ||
|| val !== val.trim() ) | ||
? JSON.stringify(val) | ||
: val.replace(/;/g, '\\;') | ||
} | ||
function unsafe (val) { | ||
function unsafe (val, doUnesc) { | ||
val = (val || "").trim() | ||
if (val.charAt(0) === "\"" && val.slice(-1) === "\"") { | ||
try { val = JSON.parse(val) } catch (_) {} | ||
} else { | ||
// walk the val to find the first not-escaped ; character | ||
var esc = false | ||
var unesc = ""; | ||
for (var i = 0, l = val.length; i < l; i++) { | ||
var c = val.charAt(i) | ||
if (esc) { | ||
if (c === "\\" || c === ";") | ||
unesc += c | ||
else | ||
unesc += "\\" + c | ||
esc = false | ||
} else if (c === ";") { | ||
break | ||
} else if (c === "\\") { | ||
esc = true | ||
} else { | ||
unesc += c | ||
} | ||
} | ||
if (esc) | ||
unesc += "\\" | ||
return unesc | ||
} | ||
return val | ||
} |
@@ -5,3 +5,3 @@ { | ||
"description": "An ini encoder/decoder for node", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -24,2 +24,3 @@ var i = require("../") | ||
+ 'a.b.c = abc\n' | ||
+ 'nocomment = this\\; this is not a comment\n' | ||
, expectD = | ||
@@ -39,3 +40,4 @@ { o: 'p', | ||
'a.b.c': { | ||
'a.b.c': 'abc' | ||
'a.b.c': 'abc', | ||
'nocomment': 'this\; this is not a comment' | ||
} | ||
@@ -42,0 +44,0 @@ } |
Sorry, the diff of this file is not supported yet
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
10125
201
0