diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-07-24 22:22:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-24 23:22:43 +0200 |
commit | 1fad6eb2acc993714fad9d333f409495f5b3d6db (patch) | |
tree | 2b00c02b7306c7ad0577cd92e71fceba0a475475 /tests/unit/fetch_test.ts | |
parent | c7f468d33b5d0814b56036639eb2a8226d4bfbbf (diff) |
fix(ext/fetch): respect authority from URL (#24705)
This commit fixes handling of "authority" in the URL by properly
sending "Authorization Basic..." header in `fetch` API.
This is a regression from https://github.com/denoland/deno/pull/24593
Fixes https://github.com/denoland/deno/issues/24697
CC @seanmonstar
Diffstat (limited to 'tests/unit/fetch_test.ts')
-rw-r--r-- | tests/unit/fetch_test.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/fetch_test.ts b/tests/unit/fetch_test.ts index bc3822d99..39cadcb44 100644 --- a/tests/unit/fetch_test.ts +++ b/tests/unit/fetch_test.ts @@ -2042,3 +2042,21 @@ Deno.test("Response with subarray TypedArray body", async () => { const expected = new Uint8Array([2, 3, 4, 5]); assertEquals(actual, expected); }); + +// Regression test for https://github.com/denoland/deno/issues/24697 +Deno.test("URL authority is used as 'Authorization' header", async () => { + const deferred = Promise.withResolvers<string | null | undefined>(); + const ac = new AbortController(); + + const server = Deno.serve({ port: 4502, signal: ac.signal }, (req) => { + deferred.resolve(req.headers.get("authorization")); + return new Response("Hello world"); + }); + + const res = await fetch("http://deno:land@localhost:4502"); + await res.text(); + const authHeader = await deferred.promise; + ac.abort(); + await server.finished; + assertEquals(authHeader, "Basic ZGVubzpsYW5k"); +}); |