Comparing version 0.0.5 to 0.0.6
90
index.js
@@ -12,74 +12,42 @@ module.exports = function(str){ | ||
for (var i=0, len=str.length; i<len; i++) { | ||
var c = str[i]; | ||
var cc = str[i+1]; | ||
if (c == "'") { | ||
if (sQuoted) { | ||
sQuoted = false; | ||
} else if (backSlash) { | ||
buffer += c; | ||
backSlash = false; | ||
} else if (dQuoted) { | ||
buffer += c; | ||
} else { | ||
sQuoted = true; | ||
} | ||
if (sQuoted && str[i] === "'") { | ||
sQuoted = false; | ||
continue; | ||
} | ||
if (c == '"') { | ||
if (sQuoted) { | ||
buffer += c; | ||
} else if (backSlash) { | ||
buffer += c; | ||
backSlash = false; | ||
} else if (dQuoted) { | ||
dQuoted = false; | ||
} else { | ||
if (!sQuoted && !dQuoted && !backSlash) { | ||
switch (str[i]) { | ||
case "'": | ||
sQuoted = true; | ||
continue; | ||
case '"': | ||
dQuoted = true; | ||
} | ||
continue; | ||
} | ||
if (c == '\\') { | ||
if (sQuoted) { | ||
buffer += c; | ||
} else if (backSlash) { | ||
buffer += c; | ||
backSlash = false; | ||
} else if (!dQuoted) { | ||
continue; | ||
case '\\': | ||
backSlash = true; | ||
} else if (~['"', '`', '$', '\\'].indexOf(cc)) { | ||
backSlash = true; | ||
} else { | ||
buffer += c; | ||
backSlash = true; | ||
} | ||
continue; | ||
} | ||
if (~['\b', '\f', '\n', '\r', '\t', ' '].indexOf(c)) { | ||
if (sQuoted) { | ||
buffer += c; | ||
} else if (backSlash) { | ||
buffer += c; | ||
backSlash = false; | ||
} else if (dQuoted) { | ||
buffer += c; | ||
} else { | ||
continue; | ||
case '\b': | ||
case '\f': | ||
case '\n': | ||
case '\r': | ||
case '\t': | ||
case ' ': | ||
if (buffer.length) res.push(buffer); | ||
buffer = ''; | ||
continue; | ||
} | ||
} | ||
if (!sQuoted && dQuoted && !backSlash && str[i] == '"') { | ||
dQuoted = false; | ||
continue; | ||
} | ||
if (sQuoted) { | ||
buffer += c; | ||
} else if (backSlash) { | ||
buffer += c; | ||
if (!sQuoted && dQuoted && !backSlash && str[i] == '\\') { | ||
backSlash = true; | ||
if (['"', '`', '$', '\\'].indexOf(str[i+1]) !== -1) { | ||
continue; | ||
} | ||
} | ||
if (backSlash) { | ||
backSlash = false; | ||
} else if (dQuoted) { | ||
buffer += c; | ||
} else { | ||
buffer += c; | ||
} | ||
buffer += str[i]; | ||
} | ||
@@ -86,0 +54,0 @@ if (buffer.length) res.push(buffer); |
{ | ||
"name": "arrgv", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Parsing string to array of args like node on bash do.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
7742
178