diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-15 07:38:53 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-15 07:38:53 +0100 |
commit | bd8788241d668994ba660b9753443f6a7a40660c (patch) | |
tree | 7ce7861ba441ed258c5d696a06769a75490942dc /editors/code | |
parent | 447d849c9ecb3d0f7783a56db429ccc526d0d8dc (diff) | |
parent | 7a8a72c38f5626aea6c8f3c2dacbb23ed166901e (diff) |
Merge #9281
9281: fix: Code: use `Uri.toString()` for URLs r=lnicola a=wxb1ank
I believe this should fix #9280. Testing is needed but I wanted to quickly push a hotfix.
Co-authored-by: wxb1ank <[email protected]>
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/net.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts index 747c02db9..5c48c74e8 100644 --- a/editors/code/src/net.ts +++ b/editors/code/src/net.ts | |||
@@ -127,17 +127,19 @@ async function downloadFile( | |||
127 | httpProxy: string | null | undefined, | 127 | httpProxy: string | null | undefined, |
128 | onProgress: (readBytes: number, totalBytes: number) => void | 128 | onProgress: (readBytes: number, totalBytes: number) => void |
129 | ): Promise<void> { | 129 | ): Promise<void> { |
130 | const urlString = url.toString(); | ||
131 | |||
130 | const res = await (() => { | 132 | const res = await (() => { |
131 | if (httpProxy) { | 133 | if (httpProxy) { |
132 | log.debug(`Downloading ${url.path} via proxy: ${httpProxy}`); | 134 | log.debug(`Downloading ${urlString} via proxy: ${httpProxy}`); |
133 | return fetch(url.path, { agent: new HttpsProxyAgent(httpProxy) }); | 135 | return fetch(urlString, { agent: new HttpsProxyAgent(httpProxy) }); |
134 | } | 136 | } |
135 | 137 | ||
136 | return fetch(url.path); | 138 | return fetch(urlString); |
137 | })(); | 139 | })(); |
138 | 140 | ||
139 | if (!res.ok) { | 141 | if (!res.ok) { |
140 | log.error("Error", res.status, "while downloading file from", url.path); | 142 | log.error("Error", res.status, "while downloading file from", urlString); |
141 | log.error({ body: await res.text(), headers: res.headers }); | 143 | log.error({ body: await res.text(), headers: res.headers }); |
142 | 144 | ||
143 | throw new Error(`Got response ${res.status} when trying to download a file.`); | 145 | throw new Error(`Got response ${res.status} when trying to download a file.`); |
@@ -146,7 +148,7 @@ async function downloadFile( | |||
146 | const totalBytes = Number(res.headers.get('content-length')); | 148 | const totalBytes = Number(res.headers.get('content-length')); |
147 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); | 149 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); |
148 | 150 | ||
149 | log.debug("Downloading file of", totalBytes, "bytes size from", url.path, "to", destFilePath.path); | 151 | log.debug("Downloading file of", totalBytes, "bytes size from", urlString, "to", destFilePath.path); |
150 | 152 | ||
151 | let readBytes = 0; | 153 | let readBytes = 0; |
152 | res.body.on("data", (chunk: Buffer) => { | 154 | res.body.on("data", (chunk: Buffer) => { |