Is there an option to prevent value of the same key being populating into an array?
#259 创建于 2018年5月13日
仓库指标
- Star
- (8,015 star)
- PR 合并指标
- (平均合并 6天 22小时) (30 天内合并 2 个 PR)
描述
Hi there,
I'm trying to figure out if qs.parse allow us to update the query key value instead of collecting those as an array from the doc, but I can not find anything about that so I'm asking here.
By default,
qs.parse('?num=1&num=2') === { num: ['1', '2'] };
Instead, I just care about the last value assigned to num in the query. i.e.
qs.parse('?num=1&num=2', { some_option: true }) === { num: '2' };
Is there a some_option to do so?
I'm working on an API and want a consistent way to handle the value. It is annoying to check if the query value is an array for a given key every single time (and it can be an object sometimes)... and at this point I decided to ignore all other value but the latest bound to the key.
But I guess people may also want only the first key value is preserved?! (e.g. that is how StarkOverflow handled their duplicated query key.)
Thanks!