(query: URLSearchParams)
| 529 | * reader who asked for 1, and {@link pickDefaultDepth} would never run. |
| 530 | */ |
| 531 | export function parseMapQuery(query: URLSearchParams): { |
| 532 | root: string | null; |
| 533 | depth: number | null; |
| 534 | } { |
| 535 | const rawDepth = query.get('depth'); |
| 536 | let depth: number | null = null; |
| 537 | if (rawDepth !== null && rawDepth !== '') { |
| 538 | depth = Number.parseInt(rawDepth, 10); |
| 539 | if (!Number.isFinite(depth) || depth < 1 || depth > MAX_DEPTH) { |
| 540 | throw badRequest(`depth must be a whole number from 1 to ${MAX_DEPTH}.`); |
| 541 | } |
| 542 | } |
| 543 | const rawRoot = query.get('root'); |
| 544 | return { root: rawRoot === null ? null : normalizeRoot(rawRoot), depth }; |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * Rename `x/(root files)` to `x` wherever the bucket is all `x` has. |
no test coverage detected