MCPcopy Index your code
hub / github.com/simstudioai/sim / parseWorkspaceFileCreatePath

Function parseWorkspaceFileCreatePath

apps/sim/lib/copilot/vfs/resource-writer.ts:73–98  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

71}
72
73export 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
100async function resolveCreateTarget(
101 workspaceId: string,

Callers 1

resolveCreateTargetFunction · 0.85

Calls 5

decodeVfsPathSegmentsFunction · 0.90
joinMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected