(path: string)
| 71 | } |
| 72 | |
| 73 | export function parseWorkspaceFileCreatePath(path: string): { |
| 74 | folderSegments: string[] |
| 75 | fileName: string |
| 76 | vfsPath: string |
| 77 | } { |
| 78 | const trimmed = path.trim().replace(/^\/+/, '') |
| 79 | if (!trimmed.startsWith('files/')) { |
| 80 | throw new Error('Workspace file paths must start with "files/"') |
| 81 | } |
| 82 | |
| 83 | const decoded = decodeVfsPathSegments(trimmed.slice('files/'.length)) |
| 84 | if (decoded.length === 0) { |
| 85 | throw new Error('Workspace file path must include a file name') |
| 86 | } |
| 87 | |
| 88 | const fileName = normalizeWorkspaceFileItemName(decoded.at(-1) ?? '', 'File') |
| 89 | const folderSegments = decoded |
| 90 | .slice(0, -1) |
| 91 | .map((segment) => normalizeWorkspaceFileItemName(segment, 'Folder')) |
| 92 | |
| 93 | return { |
| 94 | folderSegments, |
| 95 | fileName, |
| 96 | vfsPath: canonicalWorkspaceFilePath({ folderPath: folderSegments.join('/'), name: fileName }), |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | async function resolveCreateTarget( |
| 101 | workspaceId: string, |
no test coverage detected