From 04ed17ced73be4ef9c4ed3e52646b1dec2e8a69d Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Thu, 26 Oct 2023 19:18:21 +0100 Subject: [PATCH] Add regression test --- packages/miniflare/test/index.spec.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/miniflare/test/index.spec.ts b/packages/miniflare/test/index.spec.ts index 804dc1caa..d229d8595 100644 --- a/packages/miniflare/test/index.spec.ts +++ b/packages/miniflare/test/index.spec.ts @@ -514,7 +514,24 @@ test("Miniflare: fetch mocking", async (t) => { } ); }); - +test("Miniflare: custom upstream as origin (with colons)", async (t) => { + const upstream = await useServer(t, (req, res) => { + res.end(`upstream: ${new URL(req.url ?? "", "http://upstream")}`); + }); + const mf = new Miniflare({ + upstream: new URL("/extra:extra/", upstream.http.toString()).toString(), + modules: true, + script: `export default { + fetch(request) { + return fetch(request); + } + }`, + }); + t.teardown(() => mf.dispose()); + // Check rewrites protocol, hostname, and port, but keeps pathname and query + const res = await mf.dispatchFetch("https://random:0/path:path?a=1"); + t.is(await res.text(), "upstream: http://upstream/extra:extra/path:path?a=1"); +}); test("Miniflare: custom upstream as origin", async (t) => { const upstream = await useServer(t, (req, res) => { res.end(`upstream: ${new URL(req.url ?? "", "http://upstream")}`);