Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
penalosa committed Oct 26, 2023
1 parent fb592bd commit 04ed17c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/miniflare/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")}`);
Expand Down

0 comments on commit 04ed17c

Please sign in to comment.