Commit 06fca0a4 06fca0a40a13320c495ec75bc267082d828aa4f5 by Nicolas Perriault

fixes #109 - args containing = (equals sign) not parsed properly

1 parent 5ad676ab
......@@ -11,6 +11,8 @@ XXXX-XX-XX, v0.6.7
> which causes the phantomjs subprocess to completely replace the casperjs parent
> process (while maintaining the same pid). This patch also has the added benefit of
> saving 10 megs or so of memory because the python process is discarded.
- fixes [#109](https://github.com/n1k0/casperjs/issues/109) - CLI args containing `=` (equals sign) were not parsed properly
- fixes [#100](https://github.com/n1k0/casperjs/issues/100) & [#110](https://github.com/n1k0/casperjs/issues/110) - *googlepagination* sample was broken
2012-04-27, v0.6.6
------------------
......
......@@ -85,7 +85,7 @@ exports.parse = function parse(phantomArgs) {
phantomArgs.forEach(function _forEach(arg) {
if (arg.indexOf('--') === 0) {
// named option
var optionMatch = arg.match(/^--(.*)=(.*)/i);
var optionMatch = arg.match(/^--(.*?)=(.*)/i);
if (optionMatch) {
extract.options[optionMatch[1]] = castArgument(optionMatch[2]);
} else {
......
......@@ -32,10 +32,10 @@ t.comment('parse(), get(), has()');
(function(parsed) {
t.assertEquals(parsed.args, [], 'parse() returns expected positional args array');
t.assertEquals(parsed.options, { '&é"à': 42 }, 'parse() returns expected options object');
t.assertEquals(parsed.get('&é"à'), 42, 'parse() handles options with exotic names');
t.assertEquals(parsed.options, { '&é"à': "42===42" }, 'parse() returns expected options object');
t.assertEquals(parsed.get('&é"à'), "42===42", 'parse() handles options with exotic names');
t.assert(parsed.has('&é"à'), 'has() checks if an option is set');
})(cli.parse(['--&é"à=42']));
})(cli.parse(['--&é"à=42===42']));
(function(parsed) {
t.assertEquals(parsed.args, ['foo & bar', 'baz & boz'], 'parse() returns expected positional args array');
......