| 48 | * - null is returned when a value is missing for any parameter segment. |
| 49 | */ |
| 50 | export const chainToSegments = (chain: RouteChain): string[] | null => { |
| 51 | const segments = []; |
| 52 | for (const route of chain) { |
| 53 | for (const segment of route.segments) { |
| 54 | if (segment[0] === ':') { |
| 55 | // eslint-disable-next-line @typescript-eslint/prefer-optional-chain |
| 56 | const param = route.params && route.params[segment.slice(1)]; |
| 57 | if (!param) { |
| 58 | return null; |
| 59 | } |
| 60 | segments.push(param); |
| 61 | } else if (segment !== '') { |
| 62 | segments.push(segment); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | return segments; |
| 67 | }; |
| 68 | |
| 69 | /** |
| 70 | * Removes the prefix segments from the path segments. |