diff --git a/index.js b/index.js index 536fc5b..69fdd49 100644 --- a/index.js +++ b/index.js @@ -189,8 +189,8 @@ module.exports = function (args, opts) { continue; } - if ((/[A-Za-z]/).test(letters[j]) && (/[=]/).test(next)) { - setArg(letters[j], next.split('=')[1], arg); + if ((/[A-Za-z]/).test(letters[j]) && next[0] === '=') { + setArg(letters[j], next.slice(1), arg); broken = true; break; } diff --git a/test/kv_short.js b/test/kv_short.js index 1578f05..6d1b53a 100644 --- a/test/kv_short.js +++ b/test/kv_short.js @@ -16,3 +16,17 @@ test('multi short -k=v', function (t) { var argv = parse(['-a=whatever', '-b=robots']); t.deepEqual(argv, { a: 'whatever', b: 'robots', _: [] }); }); + +test('short with embedded equals -k=a=b', function (t) { + t.plan(1); + + var argv = parse(['-k=a=b']); + t.deepEqual(argv, { k: 'a=b', _: [] }); +}); + +test('short with later equals like -ab=c', function (t) { + t.plan(1); + + var argv = parse(['-ab=c']); + t.deepEqual(argv, { a: true, b: 'c', _: [] }); +});