mirror of
https://github.com/coder/code-server.git
synced 2024-11-22 19:23:16 +03:00
Fix proxying non-ASCII (#6154)
This only affects the path proxy since `req.originalUrl` is in escaped format.
This commit is contained in:
parent
2e17735795
commit
951d8ac45e
@ -11,7 +11,7 @@ const getProxyTarget = (req: Request, passthroughPath?: boolean): string => {
|
||||
return `http://0.0.0.0:${req.params.port}/${req.originalUrl}`
|
||||
}
|
||||
const query = qs.stringify(req.query)
|
||||
return `http://0.0.0.0:${req.params.port}/${req.params[0] || ""}${query ? `?${query}` : ""}`
|
||||
return encodeURI(`http://0.0.0.0:${req.params.port}${req.params[0] || ""}${query ? `?${query}` : ""}`)
|
||||
}
|
||||
|
||||
export async function proxy(
|
||||
|
@ -187,6 +187,17 @@ describe("proxy", () => {
|
||||
})
|
||||
}).rejects.toThrow()
|
||||
})
|
||||
|
||||
it("should proxy non-ASCII", async () => {
|
||||
e.get("*", (req, res) => {
|
||||
res.json("ほげ")
|
||||
})
|
||||
codeServer = await integration.setup(["--auth=none"], "")
|
||||
const resp = await codeServer.fetch(proxyPath.replace("wsup", "ほげ"))
|
||||
expect(resp.status).toBe(200)
|
||||
const json = await resp.json()
|
||||
expect(json).toBe("ほげ")
|
||||
})
|
||||
})
|
||||
|
||||
// NOTE@jsjoeio
|
||||
|
Loading…
Reference in New Issue
Block a user