MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / parsePath

Function parsePath

frontend/src/hooks/useFileManager.ts:213–230  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

211 };
212
213 const parsePath = (path: string) => {
214 if (!path) return [];
215
216 const normalizedPath = path.replace(/\\/g, "/");
217 const driveMatch = normalizedPath.match(/^([a-zA-Z]):/);
218 const driveLetter = driveMatch ? driveMatch[1] : "";
219 const pathPart = driveLetter ? normalizedPath.slice(2) : normalizedPath;
220
221 const parts = pathPart.split("/").filter(Boolean);
222 const result = driveLetter ? [driveLetter] : ["/"];
223
224 parts.forEach((_, index) => {
225 const _currentPath = "/" + parts.slice(0, index + 1).join("/");
226 result.push(index < parts.length - 1 ? _currentPath + "/" : _currentPath);
227 });
228
229 return result;
230 };
231
232 const getLastNameFromPath = (path: string) => {
233 if (path === "/") return "/";

Callers 1

updateBreadcrumbsFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected