Skip to content

Commit 9dccc3f

Browse files
committed
Avoid decoding and re-encoding URLs
1 parent 5fb2786 commit 9dccc3f

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

lib/proto/http.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ module.exports = {
3030

3131
let user_agent = opts.user_agent || `${pkg.name}/${pkg.version}`;
3232

33-
// Decoding and encoding is required to prevent encoding already encoded URLs
34-
// We decode using the decodeURIComponent as it will decode a wider range of
35-
// characters that were not necessary to be encoded at first, then we re-encode
36-
// only the required ones using encodeURI.
37-
// Note that we don't use encodeURIComponents as it adds too much non-necessary encodings
38-
// see "Not Escaped" list in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#description
39-
const url = encodeURI(decodeURIComponent(new URL(link, opts.baseUrl).toString()));
33+
const url = new URL(link, opts.baseUrl).toString();
4034

4135
const options = {
4236
agent: new ProxyAgent(),

0 commit comments

Comments
 (0)