( collection: HttpImportCollection, folderIds: Map<string, string>, folderNames: Map<string, string>, path: string, )
| 407 | } |
| 408 | |
| 409 | function ensureFolder( |
| 410 | collection: HttpImportCollection, |
| 411 | folderIds: Map<string, string>, |
| 412 | folderNames: Map<string, string>, |
| 413 | path: string, |
| 414 | ): string | null { |
| 415 | const normalized = normalizePath(path) |
| 416 | if (!normalized) |
| 417 | return null |
| 418 | |
| 419 | const segments = normalized.split('/').filter(Boolean) |
| 420 | let currentPath = '' |
| 421 | let parentId: string | null = null |
| 422 | |
| 423 | for (const segment of segments) { |
| 424 | currentPath = currentPath ? `${currentPath}/${segment}` : segment |
| 425 | const existing = folderIds.get(currentPath) |
| 426 | if (existing) { |
| 427 | parentId = existing |
| 428 | continue |
| 429 | } |
| 430 | |
| 431 | const id = currentPath |
| 432 | const folder: HttpImportFolder = { |
| 433 | id, |
| 434 | name: normalizeImportName(folderNames.get(currentPath), segment), |
| 435 | parentId, |
| 436 | } |
| 437 | folderIds.set(currentPath, id) |
| 438 | collection.folders.push(folder) |
| 439 | parentId = id |
| 440 | } |
| 441 | |
| 442 | return parentId |
| 443 | } |
| 444 | |
| 445 | function parseBundledItems( |
| 446 | items: unknown[], |
no test coverage detected