(hash: string)
| 42 | | { readonly kind: "auth"; readonly domain: string }; |
| 43 | |
| 44 | const parseRoute = (hash: string): NextRoute => { |
| 45 | // `#reworked/...` is canonical; `#next/...` is kept working because it was |
| 46 | // the first spelling and may already be pasted somewhere. |
| 47 | const path = hash.replace(/^#/, "").replace(/^(reworked|next)\/?/, ""); |
| 48 | const segments = path.split("/").filter((segment) => segment.length > 0); |
| 49 | if (segments.length === 0) return { kind: "browse" }; |
| 50 | const [first, second] = segments; |
| 51 | if (first === "installed") return { kind: "installed" }; |
| 52 | if (first === "custom") return { kind: "custom" }; |
| 53 | if (first && second === "auth") return { kind: "auth", domain: first }; |
| 54 | if (first) return { kind: "detail", domain: first }; |
| 55 | return { kind: "browse" }; |
| 56 | }; |
| 57 | |
| 58 | const routeToHash = (route: NextRoute): string => { |
| 59 | if (route.kind === "browse") return "#reworked"; |
no test coverage detected