@@ -546,7 +546,7 @@ export interface PathSegmentLayout {
|
546 | 546 | |
547 | 547 | export function getPathLayout(path: OcPath): PathSegmentLayout { |
548 | 548 | // Quote-aware split — `.split('.')` would shred a quoted segment |
549 | | -// containing a literal `.` (e.g. `"a.b"`) and break repackPath. |
| 549 | +// containing a literal `.` (e.g. `"a.b"`). |
550 | 550 | const sectionSubs = path.section === undefined ? [] : splitRespectingBrackets(path.section, "."); |
551 | 551 | const itemSubs = path.item === undefined ? [] : splitRespectingBrackets(path.item, "."); |
552 | 552 | const fieldSubs = path.field === undefined ? [] : splitRespectingBrackets(path.field, "."); |
@@ -558,31 +558,6 @@ export function getPathLayout(path: OcPath): PathSegmentLayout {
|
558 | 558 | }; |
559 | 559 | } |
560 | 560 | |
561 | | -/** |
562 | | - * Re-pack a concrete sub-segment list into an `OcPath` preserving the |
563 | | - * pattern's slot boundaries. Throws on length mismatch. |
564 | | - */ |
565 | | -export function repackPath(pattern: OcPath, subs: readonly string[]): OcPath { |
566 | | -const layout = getPathLayout(pattern); |
567 | | -if (subs.length !== layout.subs.length) { |
568 | | -fail( |
569 | | -`repack length mismatch: pattern has ${layout.subs.length} sub-segments, got ${subs.length}`, |
570 | | -formatOcPath(pattern), |
571 | | -"OC_PATH_REPACK_LENGTH", |
572 | | -); |
573 | | -} |
574 | | -const sectionSubs = subs.slice(0, layout.sectionLen); |
575 | | -const itemSubs = subs.slice(layout.sectionLen, layout.sectionLen + layout.itemLen); |
576 | | -const fieldSubs = subs.slice(layout.sectionLen + layout.itemLen); |
577 | | -return { |
578 | | -file: pattern.file, |
579 | | - ...(sectionSubs.length > 0 ? { section: sectionSubs.join(".") } : {}), |
580 | | - ...(itemSubs.length > 0 ? { item: itemSubs.join(".") } : {}), |
581 | | - ...(fieldSubs.length > 0 ? { field: fieldSubs.join(".") } : {}), |
582 | | - ...(pattern.session !== undefined ? { session: pattern.session } : {}), |
583 | | -}; |
584 | | -} |
585 | | - |
586 | 561 | function extractSession(queryPart: string, input: string): string | undefined { |
587 | 562 | if (queryPart.length === 0) { |
588 | 563 | return undefined; |
|