(segment: string)
| 21 | } |
| 22 | |
| 23 | export function decodeVfsSegment(segment: string): string { |
| 24 | try { |
| 25 | const decoded = decodeURIComponent(segment) |
| 26 | const normalized = normalizeDisplaySegment(decoded) |
| 27 | if (!normalized || normalized === '.' || normalized === '..') { |
| 28 | throw new VfsPathError('VFS path segment cannot be empty or a dot segment') |
| 29 | } |
| 30 | return normalized |
| 31 | } catch (error) { |
| 32 | if (error instanceof VfsPathError) throw error |
| 33 | throw new VfsPathError(`Invalid encoded VFS path segment: ${segment}`) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | export function encodeVfsPathSegments(segments: string[]): string { |
| 38 | return segments.map(encodeVfsSegment).join('/') |
no test coverage detected