Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "splitargs", | ||
"version": "0.0.5", | ||
"description": "Splits strings into tokens by given separator except treating quoted part as a single token.", | ||
"main": "splitargs.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/elgs/splitargs" | ||
}, | ||
"keywords": [ | ||
"split", | ||
"args", | ||
"quoted", | ||
"space" | ||
], | ||
"author": "Elgs Chen", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/elgs/splitargs/issues" | ||
}, | ||
"homepage": "https://github.com/elgs/splitargs" | ||
"name": "splitargs", | ||
"version": "0.0.6", | ||
"description": "Splits strings into tokens by given separator except treating quoted part as a single token.", | ||
"main": "splitargs.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/elgs/splitargs" | ||
}, | ||
"keywords": [ | ||
"split", | ||
"args", | ||
"quoted", | ||
"space" | ||
], | ||
"author": "Elgs Chen", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/elgs/splitargs/issues" | ||
}, | ||
"homepage": "https://github.com/elgs/splitargs" | ||
} |
@@ -8,4 +8,4 @@ /** | ||
module.exports = function (input, separator, keepQuotes) { | ||
separator = separator || /\s/g; | ||
module.exports = function (input, sep, keepQuotes) { | ||
var separator = sep || /\s/g; | ||
var singleQuoteOpen = false; | ||
@@ -35,8 +35,9 @@ var doubleQuoteOpen = false; | ||
if (!singleQuoteOpen && !doubleQuoteOpen && matches) { | ||
if (tokenBuffer && tokenBuffer.length > 0) { | ||
if (tokenBuffer.length > 0) { | ||
ret.push(tokenBuffer.join('')); | ||
tokenBuffer = []; | ||
} else { | ||
} else if (!!sep) { | ||
ret.push(''); | ||
} | ||
} else { | ||
@@ -43,0 +44,0 @@ tokenBuffer.push(element); |
@@ -17,3 +17,3 @@ /** | ||
it('should split double quoted string', function () { | ||
var i = "I said 'I am sorry.', and he said \"it doesn't matter.\""; | ||
var i = "I said 'I am sorry.', and he said \"it doesn't matter.\""; | ||
var o = splitargs(i); | ||
@@ -20,0 +20,0 @@ expect(o.length).toBe(7); |
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
6230