(event: EventLike)
| 23 | * otherwise falls back to getOwnPropertyDescriptor for SvelteKit 1.x. |
| 24 | */ |
| 25 | export function getRouteId(event: EventLike): string | void { |
| 26 | if (typeof event.untrack === 'function') { |
| 27 | return event.untrack(() => event.route?.id ?? undefined); |
| 28 | } |
| 29 | |
| 30 | const route = event.route; |
| 31 | if (!route) { |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | const descriptor = Object.getOwnPropertyDescriptor(route, 'id'); |
| 36 | const fromDescriptor = descriptor?.value as string | null | undefined; |
| 37 | |
| 38 | if (fromDescriptor !== undefined && fromDescriptor !== null) { |
| 39 | return fromDescriptor; |
| 40 | } |
| 41 | |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Determines if a thrown "error" is a Redirect object which SvelteKit users can throw to redirect to another route |
no test coverage detected