(segmentGroup: UrlSegmentGroup, startIndex: number, commands: readonly any[])
| 479 | } |
| 480 | |
| 481 | function prefixedWith(segmentGroup: UrlSegmentGroup, startIndex: number, commands: readonly any[]) { |
| 482 | let currentCommandIndex = 0; |
| 483 | let currentPathIndex = startIndex; |
| 484 | |
| 485 | const noMatch = {match: false, pathIndex: 0, commandIndex: 0}; |
| 486 | while (currentPathIndex < segmentGroup.segments.length) { |
| 487 | if (currentCommandIndex >= commands.length) return noMatch; |
| 488 | const path = segmentGroup.segments[currentPathIndex]; |
| 489 | const command = commands[currentCommandIndex]; |
| 490 | // Do not try to consume command as part of the prefixing if it has outlets because it can |
| 491 | // contain outlets other than the one being processed. Consuming the outlets command would |
| 492 | // result in other outlets being ignored. |
| 493 | if (isCommandWithOutlets(command)) { |
| 494 | break; |
| 495 | } |
| 496 | const curr = `${command}`; |
| 497 | const next = |
| 498 | currentCommandIndex < commands.length - 1 ? commands[currentCommandIndex + 1] : null; |
| 499 | |
| 500 | if (currentPathIndex > 0 && curr === undefined) break; |
| 501 | |
| 502 | if (curr && next && typeof next === 'object' && next.outlets === undefined) { |
| 503 | if (!compare(curr, next, path)) return noMatch; |
| 504 | currentCommandIndex += 2; |
| 505 | } else { |
| 506 | if (!compare(curr, {}, path)) return noMatch; |
| 507 | currentCommandIndex++; |
| 508 | } |
| 509 | currentPathIndex++; |
| 510 | } |
| 511 | |
| 512 | return {match: true, pathIndex: currentPathIndex, commandIndex: currentCommandIndex}; |
| 513 | } |
| 514 | |
| 515 | function createNewSegmentGroup( |
| 516 | segmentGroup: UrlSegmentGroup, |
no test coverage detected