MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / normalizePath

Function normalizePath

packages/web/src/features/git/utils.ts:19–38  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

17}
18
19export const normalizePath = (path: string): string => {
20 // Normalize the path by...
21 let normalizedPath = path;
22
23 // ... adding a trailing slash if it doesn't have one.
24 // This is important since ls-tree won't return the contents
25 // of a directory if it doesn't have a trailing slash.
26 if (!normalizedPath.endsWith('/')) {
27 normalizedPath = `${normalizedPath}/`;
28 }
29
30 // ... removing any leading slashes. This is needed since
31 // the path is relative to the repository's root, so we
32 // need a relative path.
33 if (normalizedPath.startsWith('/')) {
34 normalizedPath = normalizedPath.slice(1);
35 }
36
37 return normalizedPath;
38}
39
40export const compareFileTreeItems = (a: FileTreeItem, b: FileTreeItem): number => {
41 if (a.type !== b.type) {

Callers 3

getFolderContentsFunction · 0.90
getTreeFunction · 0.90
utils.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected