-
-
Notifications
You must be signed in to change notification settings - Fork 935
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
Spaces should be normalized as +
in query strings
#1113
Comments
I cannot reproduce, can you create a RunKit example? |
@szmarczak Copy and paste this into npm.runkit.com: const got = require("got")
const queryString = require("query-string")
console.log((await got(`http://example.com`, {
searchParams: queryString.stringify({
a: "b c"
}).replace(/\+/, "%20")
})).url) It is supposed to log a URL with |
You're using the |
%20
to be used instead of +
for spaces
@sindresorhus This is inconsistent: new URL('https://example.com/?a=b c').toString()
"https://example.com/?a=b%20c"
new URLSearchParams('a=b c').toString()
"a=b+c" |
const url = new URL('https://example.com/?a=b c');
url.search
"?a=b%20c"
url.searchParams.toString()
"a=b+c" |
The WHATWG URL says that:
|
|
|
You should make an issue there instead. WHATWG URL is a standard and |
Modifying @sindresorhus Maybe let's do |
+
in query strings
Since this works, it sounds like the original issue is more likely a Node.js bug in the URL implementation?
Some people unfortunately depend on the order. I experienced that with https://github.com/sindresorhus/query-string However, maybe we can just add a random obscure value and remove it again. Does that cause it to normalize? Like |
How is it a bug in V8? I would prefer workaround number 3. |
The bug also appears in browsers... |
@szmarczak That doesn't necessarily mean it's a bug in V8 though. Both the browser and Node.js URL implementation is based on the same spec and might have the same implementation bug or spec bug. |
There's a spec bug for the inconsistency between The implementation for |
I just observed the same issue – it’s not uncommon for web servers to not accept Workaround’s the same as the OP: cannot use |
We do everything according to the spec, if they don't follow it - email them. |
What problem are you trying to solve?
Some web services like the VLC Web Interface use
%20
to represent spaces in search params. However, Got automatically forces+
with no way to override it even if put throughquery-string
.Describe the feature
The simplest solution would be to allow such overrides using the current syntax:
The current workaround is to insert it directly into the url:
See: https://github.com/Richienb/vlc/blob/62f395cd471cf9cad0c540bad3aade8d2a7faa6f/src/index.ts#L169-L175
Checklist
The text was updated successfully, but these errors were encountered: