Closed
Description
Consider this block:
Lines 52 to 66 in 62fde7d
Here it builds an array of aliased args:
Lines 55 to 57 in 62fde7d
And here it uses this array as a key for strings:
Line 64 in 62fde7d
Which will just result in:
{
strings: {
"[object Object]": true
}
}
It should either build flat aliases or iterate over the nested array
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]Using an array as object key[/-][+]Using an array as an object key[/+]ljharb commentedon Oct 18, 2022
Is there a test case you can suggest that indicates the problem?
nhz-io commentedon Oct 18, 2022
Actually, the array will be turned into string joined with comma. But regardless, the logic still seems broken to me.
I will update later if i find a use case where this breaks the functionalilty.
ljharb commentedon Oct 18, 2022
In which browser is an array used as an object key not toStringed such that it auto-joins?
nhz-io commentedon Oct 18, 2022
My mistake. It something i messed up it seems
nhz-io commentedon Oct 18, 2022
Found the case where it breaks.
Its an edge-case, but its still breaks the convention
ljharb commentedon Oct 18, 2022
The readme indeed says "an object mapping string names to strings or arrays of string argument names to use as aliases", so this seems like a bug.
shadowspawn commentedon Oct 18, 2022
Took me a while to make sense of it, but I agree it is a bug. An alias with multiple items does not play well with the
opts.string
configuration.(I suspect there are some holes in the combination of aliases with
opts.boolean
too, butaliasIsBoolean()
means the edge cases are quite different. Separate issue.)add issue minimistjs#9 fix test
fix issue minimistjs#9
nhz-io commentedon Oct 18, 2022
Well, aliases cannot be flat without breaking this:
minimist/index.js
Lines 125 to 127 in 62fde7d
[Fix] opt.string works with multiple aliases
12 remaining items