(self: HttpServerRequest)
| 1023 | * @since 4.0.0 |
| 1024 | */ |
| 1025 | export const toURL = (self: HttpServerRequest): Option.Option<URL> => { |
| 1026 | const host = self.headers.host ?? "localhost" |
| 1027 | const protocol = self.headers["x-forwarded-proto"] === "https" ? "https" : "http" |
| 1028 | try { |
| 1029 | return Option.some(new URL(self.url, `${protocol}://${host}`)) |
| 1030 | } catch { |
| 1031 | return Option.none() |
| 1032 | } |
| 1033 | } |
| 1034 | |
| 1035 | /** |
| 1036 | * Converts an `HttpServerRequest` safely to a Web `Request` as a `Result`. |
no test coverage detected