fix(fetch): use new URL to properly encode URLs

This commit is contained in:
Zoltan Kochan
2019-06-02 22:34:32 +03:00
parent 257a77ac51
commit 87b696e4e1

View File

@@ -1,5 +1,6 @@
import fetch from '@pnpm/fetch'
import npmRegistryAgent from '@pnpm/npm-registry-agent'
import { URL } from 'url'
const USER_AGENT = 'pnpm' // or maybe make it `${pkg.name}/${pkg.version} (+https://npm.im/${pkg.name})`
@@ -57,7 +58,11 @@ export default function (
...opts,
} as any) // tslint:disable-line
headers['connection'] = agent ? 'keep-alive' : 'close'
let response = await fetch(url, {
// We should pass a URL object to node-fetch till this is not resolved:
// https://github.com/bitinn/node-fetch/issues/245
const urlObject = new URL(url)
let response = await fetch(urlObject, {
agent,
// if verifying integrity, node-fetch must not decompress
compress: false,