(url: URL, path: string, locale?: string)
| 24 | } |
| 25 | |
| 26 | function redirect(url: URL, path: string, locale?: string) { |
| 27 | const next = new URL(url.toString()) |
| 28 | next.pathname = path |
| 29 | const headers = new Headers({ |
| 30 | Location: next.toString(), |
| 31 | }) |
| 32 | if (locale) headers.set("Set-Cookie", cookie(locale)) |
| 33 | return new Response(null, { |
| 34 | status: 302, |
| 35 | headers, |
| 36 | }) |
| 37 | } |
| 38 | |
| 39 | function localeFromCookie(header: string | null) { |
| 40 | if (!header) return null |
no test coverage detected