( headers: Headers, upstream: URL, proxyOrigin: string, )
| 247 | } |
| 248 | |
| 249 | function rewriteLocationHeader( |
| 250 | headers: Headers, |
| 251 | upstream: URL, |
| 252 | proxyOrigin: string, |
| 253 | ): void { |
| 254 | const location = headers.get("Location"); |
| 255 | if (!location) return; |
| 256 | |
| 257 | const rewritten = new URL(location, upstream); |
| 258 | if (rewritten.origin === upstream.origin) { |
| 259 | headers.set( |
| 260 | "Location", |
| 261 | `${proxyOrigin}${rewritten.pathname}${rewritten.search}${rewritten.hash}`, |
| 262 | ); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | function parseEncodedSession(value: string): EncodedSession { |
| 267 | const decoded = base64UrlDecode(value); |
no test coverage detected