Skip to content

Commit

Permalink
Support URL objects in HttpServerResponse.redirect (#4154)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilkybarkid authored Dec 18, 2024
1 parent e66b920 commit 05d71f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-buttons-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform": patch
---

Support URL objects in HttpServerResponse.redirect
2 changes: 1 addition & 1 deletion packages/platform/src/HttpServerResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const empty: (options?: Options.WithContent | undefined) => HttpServerRes
* @since 1.0.0
* @category constructors
*/
export const redirect: (location: string, options?: Options.WithContentType | undefined) => HttpServerResponse =
export const redirect: (location: string | URL, options?: Options.WithContentType | undefined) => HttpServerResponse =
internal.redirect

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/platform/src/internal/httpServerResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ export const empty = (options?: ServerResponse.Options.WithContent | undefined):

/** @internal */
export const redirect = (
location: string,
location: string | URL,
options?: ServerResponse.Options.WithContentType | undefined
): ServerResponse.HttpServerResponse => {
const headers = Headers.unsafeFromRecord({ location })
const headers = Headers.unsafeFromRecord({ location: location.toString() })
return new ServerResponseImpl(
options?.status ?? 301,
options?.statusText,
Expand Down

0 comments on commit 05d71f8

Please sign in to comment.