Comparing version 1.0.1 to 1.0.2
11
index.js
@@ -9,2 +9,3 @@ module.exports = str => { | ||
let backSlash = false; | ||
let notEmpty = false; | ||
let buffer = ''; | ||
@@ -15,2 +16,3 @@ | ||
sQuoted = false; | ||
notEmpty = true; | ||
return; | ||
@@ -32,4 +34,5 @@ } | ||
if(['\b', '\f', '\n', '\r', '\t', ' '].includes(v)){ | ||
if(buffer.length > 0){ | ||
if(buffer.length > 0 || notEmpty){ | ||
res.push(buffer); | ||
notEmpty = false; | ||
} | ||
@@ -42,2 +45,3 @@ buffer = ''; | ||
dQuoted = false; | ||
notEmpty = true; | ||
return; | ||
@@ -57,3 +61,6 @@ } | ||
if(buffer.length > 0) res.push(buffer); | ||
if(buffer.length > 0 || notEmpty){ | ||
res.push(buffer); | ||
notEmpty = false; | ||
} | ||
if(dQuoted) throw new SyntaxError('unexpected end of string while looking for matching double quote'); | ||
@@ -60,0 +67,0 @@ if(sQuoted) throw new SyntaxError('unexpected end of string while looking for matching single quote'); |
{ | ||
"name": "arrgv", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Parsing string to array of args like node on bash do.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,2 +29,4 @@ const test = require('ava'); | ||
t.deepEqual(arrgv('aaa b"bb cc"c ddd'), ['aaa', 'bbb ccc', 'ddd'], 'double quotes in words make string arg'); | ||
t.deepEqual(arrgv('aaa "" bbb'), ['aaa', '', 'bbb'], 'empty string in double quotes'); | ||
t.deepEqual(arrgv('aaa ""'), ['aaa', ''], 'empty string in double quotes on last position'); | ||
}); | ||
@@ -39,2 +41,4 @@ | ||
t.deepEqual(arrgv(`aaa b'bb cc'c ddd`), ['aaa', 'bbb ccc', 'ddd'], 'single quotes in words make string arg'); | ||
t.deepEqual(arrgv(`aaa '' bbb`), ['aaa', '', 'bbb'], 'empty string in single quotes'); | ||
t.deepEqual(arrgv(`aaa ''`), ['aaa', ''], 'empty string in single quotes on last position'); | ||
}); | ||
@@ -41,0 +45,0 @@ |
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
9073
214462
126