* Recompute a route node's `name` by prepending `prefix` to the *original* * in-file path. The original is recovered from `qualifiedName`, which the * per-file extract emits as `${filePath}::${method}:${path}` and which this * pass deliberately never mutates — that's what keeps the update idempot
(route: Node, prefix: string)
| 662 | * pass deliberately never mutates — that's what keeps the update idempotent. |
| 663 | */ |
| 664 | function applyModulePrefix(route: Node, prefix: string): Node | null { |
| 665 | const sep = '::'; |
| 666 | const idx = route.qualifiedName.indexOf(sep); |
| 667 | if (idx < 0) return null; |
| 668 | const tail = route.qualifiedName.slice(idx + sep.length); |
| 669 | const colon = tail.indexOf(':'); |
| 670 | if (colon < 0) return null; |
| 671 | const method = tail.slice(0, colon); |
| 672 | const original = tail.slice(colon + 1); |
| 673 | const newName = `${method} ${joinHttpPath(prefix, original)}`; |
| 674 | return { ...route, name: newName, updatedAt: Date.now() }; |
| 675 | } |
| 676 | |
| 677 | // --------------------------------------------------------------------------- |
| 678 | // Small string utilities (object/array literal splitters) |
no test coverage detected