Skip to content

Commit 951d8ac

Browse files
authored
Fix proxying non-ASCII (#6154)
This only affects the path proxy since `req.originalUrl` is in escaped format.
1 parent 2e17735 commit 951d8ac

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/node/routes/pathProxy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getProxyTarget = (req: Request, passthroughPath?: boolean): string => {
1111
return `http://0.0.0.0:${req.params.port}/${req.originalUrl}`
1212
}
1313
const query = qs.stringify(req.query)
14-
return `http://0.0.0.0:${req.params.port}/${req.params[0] || ""}${query ? `?${query}` : ""}`
14+
return encodeURI(`http://0.0.0.0:${req.params.port}${req.params[0] || ""}${query ? `?${query}` : ""}`)
1515
}
1616

1717
export async function proxy(

test/unit/node/proxy.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,17 @@ describe("proxy", () => {
187187
})
188188
}).rejects.toThrow()
189189
})
190+
191+
it("should proxy non-ASCII", async () => {
192+
e.get("*", (req, res) => {
193+
res.json("ほげ")
194+
})
195+
codeServer = await integration.setup(["--auth=none"], "")
196+
const resp = await codeServer.fetch(proxyPath.replace("wsup", "ほげ"))
197+
expect(resp.status).toBe(200)
198+
const json = await resp.json()
199+
expect(json).toBe("ほげ")
200+
})
190201
})
191202

192203
// NOTE@jsjoeio

0 commit comments

Comments
 (0)