From 4aeac64ecd82d5953bdb92916248f5f7352be4f4 Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Mon, 13 Jul 2020 06:53:36 +0200 Subject: fix(cli/fetch): fix relative redirect (#6715) --- cli/tests/unit/fetch_test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cli/tests/unit/fetch_test.ts') diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index 84f2c2822..c93cc0c85 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -335,6 +335,27 @@ unitTest( } ); +unitTest( + { + perms: { net: true }, + }, + async function fetchWithRelativeRedirectionUrl(): Promise { + const cases = [ + ["end", "http://localhost:4550/a/b/end"], + ["/end", "http://localhost:4550/end"], + ]; + for (const [loc, redUrl] of cases) { + const response = await fetch("http://localhost:4550/a/b/c", { + headers: new Headers([["x-location", loc]]), + }); + assertEquals(response.url, redUrl); + assertEquals(response.redirected, true); + assertEquals(response.status, 404); + assertEquals(await response.text(), ""); + } + } +); + unitTest( { perms: { net: true }, -- cgit v1.2.3