New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strip inital question mark from query string if present #177
Comments
That would potentially be a breaking change for anyone relying on that behavior. |
True. I can't imagine why someone would want that behaviour, but just because I can't imagine it doesn't mean it's not possible :) |
When |
@dougwilson Thanks! could you provide an example POST that would result in a leading |
Any POST body... the body is a literal, so if it starts with a |
To be clearer: I really don't care if this module wants to strip the first function parseLiteral (str) {
if (str[0]) === '?') return qs.parse('?' + str) // double ? to preserve the ?
else return qs.parse(str)
} which is a lame thing :( |
In that case I think this should simply be an option to |
I think a POST body is the use-case I hadn't been imagining! Given @dougwilson's observations, I agree qs shouldn't strip leading question marks by default. It's then hard to see an option which would be simpler to use then just
since |
That's also fine, although an option that is able to detect and remove the first |
Why not an optional argument to control this? This should not break something. |
@DanielRuf that's what my previous comment is suggesting. |
since this is mainly related w/ parsing the URL itself which turns into a get qs.parse(location.search, {type: 'get'}); or maybe a wrapper? qs.parseGet(location.search); |
The former is a bit generic, and the latter is a whole extra API to support - I'd probably make the option |
Right. Optional parameters which default to false. |
When I asked the original question, I thought it might be a simple request; I now realise how wrong I was. I thought that if the initial question mark was never required, it might be nice to be able to write
rather than
@dougwilson pointed out why this was naive; for my use-case, simply using So just to say – if @ljharb sees other use-cases, that's good, but don't do it for me! I'm quite happy for this issue to be closed, I'll leave it to you whether you want to run with it. |
I think something like @ljharb suggested would still be a bit more syntactic sugar than a slice. |
This is done in #213. |
Great, thanks for letting us know =) |
Could any leading question mark be removed from the query string supplied to
qs.parse()
?Currently if the query string supplied to
qs.parse()
has the initial question mark, it gets included in the property name of the parsed object:This can be removed manually (
qs.parse(location.search.slice(1))
), but it would be nicer not to have to do that, and I cannot see any case where the question mark would want to be retained.The text was updated successfully, but these errors were encountered: