(toPath: string, fromPath: string)
| 182 | * ``` |
| 183 | */ |
| 184 | export function buildPathWithParams(toPath: string, fromPath: string): string { |
| 185 | if (toPath[0] !== '/') { |
| 186 | throw new Error(`Invalid toPath: The string must start with a '/'. Received: '${toPath}'`); |
| 187 | } |
| 188 | |
| 189 | if (fromPath[0] !== '/') { |
| 190 | throw new Error(`Invalid fromPath: The string must start with a '/'. Received: '${fromPath}'`); |
| 191 | } |
| 192 | |
| 193 | if (!toPath.includes('/*')) { |
| 194 | return toPath; |
| 195 | } |
| 196 | |
| 197 | const fromPathParts = fromPath.split('/'); |
| 198 | const toPathParts = toPath.split('/'); |
| 199 | const resolvedParts = toPathParts.map((part, index) => |
| 200 | toPathParts[index] === '*' ? fromPathParts[index] : part, |
| 201 | ); |
| 202 | |
| 203 | return joinUrlParts(...resolvedParts); |
| 204 | } |
| 205 | |
| 206 | const MATRIX_PARAMS_REGEX = /;[^/]+/g; |
| 207 |
no test coverage detected