MCPcopy Index your code
hub / github.com/coder/coder / validatePath

Function validatePath

site/src/utils/filetree.ts:27–40  ·  view source on GitHub ↗
(
	path: string,
	fileTree: FileTree,
)

Source from the content-addressed store, hash-verified

25};
26
27export const validatePath = (
28 path: string,
29 fileTree: FileTree,
30): string | undefined => {
31 const paths = path.split("/");
32 paths.pop(); // The last item is the filename
33 for (let i = 0; i <= paths.length; i++) {
34 const path = paths.slice(0, i + 1);
35 const pathStr = path.join("/");
36 if (existsFile(pathStr, fileTree) && !isFolder(pathStr, fileTree)) {
37 return `Invalid path. The path ${path} is not a folder`;
38 }
39 }
40};
41
42export const updateFile = (
43 path: string,

Callers 2

handleConfirmFunction · 0.90
createFileFunction · 0.85

Calls 2

existsFileFunction · 0.85
isFolderFunction · 0.70

Tested by

no test coverage detected