diff --git a/lib/yargs-parser.ts b/lib/yargs-parser.ts index 571a0cbc..5f776705 100644 --- a/lib/yargs-parser.ts +++ b/lib/yargs-parser.ts @@ -225,7 +225,7 @@ export class YargsParser { if (arg !== '--' && isUnknownOptionAsArg(arg)) { pushPositional(arg) // ---, ---=, ----, etc, - } else if (truncatedArg.match(/---+(=|$)/)) { + } else if (truncatedArg.match(/^---+(=|$)/)) { // options without key name are invalid. pushPositional(arg) continue diff --git a/test/yargs-parser.cjs b/test/yargs-parser.cjs index aa6bf6bf..97add48c 100644 --- a/test/yargs-parser.cjs +++ b/test/yargs-parser.cjs @@ -3588,6 +3588,13 @@ describe('yargs-parser', function () { args.bar.should.equal('--goodnight moon') }) + // see: https://github.com/yargs/yargs-parser/issues/433 + it('handles strings with three or more trailing dashes', function () { + const args = parser('--foo "hello---" --bar="world---"') + args.foo.should.equal('hello---') + args.bar.should.equal('world---') + }) + it('respects inner quotes (string)', function () { const args = parser('cmd --foo ""Hello"" --bar ""World"" --baz="":)""') args.foo.should.equal('"Hello"')