main
| 1 | import type { NextConfig } from "next" |
| 2 | |
| 3 | type CatchBadRedirectsOptions = Awaited< |
| 4 | ReturnType<NonNullable<NextConfig["redirects"]>> |
| 5 | > |
| 6 | |
| 7 | export const catchBadRedirects = (redirects: CatchBadRedirectsOptions) => { |
| 8 | for (const redirect of redirects) { |
| 9 | if (redirect.source === redirect.destination) { |
| 10 | throw new Error( |
| 11 | `Redirect source and destination are the same: ${JSON.stringify(redirect, null, 2)}` |
| 12 | ) |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | return redirects |
| 17 | } |