summaryrefslogtreecommitdiff
path: root/cli/tests/unit/fetch_test.ts
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2020-07-13 06:53:36 +0200
committerGitHub <noreply@github.com>2020-07-13 00:53:36 -0400
commit4aeac64ecd82d5953bdb92916248f5f7352be4f4 (patch)
tree902111fada801eafc41141d68d865e1ce0ccafa9 /cli/tests/unit/fetch_test.ts
parentac000341db0c90012a6330f66bd7bebe44c9c872 (diff)
fix(cli/fetch): fix relative redirect (#6715)
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r--cli/tests/unit/fetch_test.ts21
1 files changed, 21 insertions, 0 deletions
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
@@ -339,6 +339,27 @@ unitTest(
{
perms: { net: true },
},
+ async function fetchWithRelativeRedirectionUrl(): Promise<void> {
+ 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 },
+ },
async function fetchWithInfRedirection(): Promise<void> {
const response = await fetch("http://localhost:4549/cli/tests"); // will redirect to the same place
assertEquals(response.status, 0); // network error