( segmentGroup: UrlSegmentGroup, startIndex: number, commands: readonly any[], )
| 508 | } |
| 509 | |
| 510 | function createNewSegmentGroup( |
| 511 | segmentGroup: UrlSegmentGroup, |
| 512 | startIndex: number, |
| 513 | commands: readonly any[], |
| 514 | ): UrlSegmentGroup { |
| 515 | const paths = segmentGroup.segments.slice(0, startIndex); |
| 516 | |
| 517 | let i = 0; |
| 518 | while (i < commands.length) { |
| 519 | const command = commands[i]; |
| 520 | if (isCommandWithOutlets(command)) { |
| 521 | const children = createNewSegmentChildren(command.outlets); |
| 522 | return new UrlSegmentGroup(paths, children); |
| 523 | } |
| 524 | |
| 525 | // if we start with an object literal, we need to reuse the path part from the segment |
| 526 | if (i === 0 && isMatrixParams(commands[0])) { |
| 527 | const p = segmentGroup.segments[startIndex]; |
| 528 | paths.push(new UrlSegment(p.path, stringify(commands[0]))); |
| 529 | i++; |
| 530 | continue; |
| 531 | } |
| 532 | |
| 533 | const curr = isCommandWithOutlets(command) ? command.outlets[PRIMARY_OUTLET] : `${command}`; |
| 534 | const next = i < commands.length - 1 ? commands[i + 1] : null; |
| 535 | if (curr && next && isMatrixParams(next)) { |
| 536 | paths.push(new UrlSegment(curr, stringify(next))); |
| 537 | i += 2; |
| 538 | } else { |
| 539 | paths.push(new UrlSegment(curr, {})); |
| 540 | i++; |
| 541 | } |
| 542 | } |
| 543 | return new UrlSegmentGroup(paths, {}); |
| 544 | } |
| 545 | |
| 546 | function createNewSegmentChildren(outlets: {[name: string]: readonly unknown[] | string}): { |
| 547 | [outlet: string]: UrlSegmentGroup; |
no test coverage detected
searching dependent graphs…