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