Skip to content

Commit

Permalink
Fix following relative locations
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilkybarkid committed Jan 17, 2025
1 parent ce0e614 commit 3fe172a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tiny-onions-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform": patch
---

Fix following relative locations
2 changes: 1 addition & 1 deletion packages/platform/src/internal/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ export const followRedirects = dual<
? loop(
internalRequest.setUrl(
request,
response.headers.location
new URL(response.headers.location, response.request.url)
),
redirects + 1
)
Expand Down
16 changes: 16 additions & 0 deletions packages/platform/test/HttpClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,20 @@ describe("HttpClient", () => {
body: { _id: "@effect/platform/HttpBody", _tag: "Empty" }
})
})

it("followRedirects", () =>
Effect.gen(function*(_) {
const defaultClient = yield* HttpClient.HttpClient
const client = defaultClient.pipe(HttpClient.followRedirects())

const response = yield* _(
client.get("https://google.com/"),
Effect.scoped
)
expect(response.request.url).toBe("https://www.google.com/")
}).pipe(
Effect.provide(FetchHttpClient.layer),
Effect.provideService(FetchHttpClient.RequestInit, { redirect: "manual" }),
Effect.runPromise
))
})

0 comments on commit 3fe172a

Please sign in to comment.