MCPcopy Create free account
hub / github.com/codeaashu/claude-code / parsePartialPath

Function parsePartialPath

src/utils/suggestions/directoryCompletion.ts:55–78  ·  view source on GitHub ↗
(
  partialPath: string,
  basePath?: string,
)

Source from the content-addressed store, hash-verified

53 * Parses a partial path into directory and prefix components
54 */
55export function parsePartialPath(
56 partialPath: string,
57 basePath?: string,
58): ParsedPath {
59 // Handle empty input
60 if (!partialPath) {
61 const directory = basePath || getCwd()
62 return { directory, prefix: '' }
63 }
64
65 const resolved = expandPath(partialPath, basePath)
66
67 // If path ends with separator, treat as directory with no prefix
68 // Handle both forward slash and platform-specific separator
69 if (partialPath.endsWith('/') || partialPath.endsWith(sep)) {
70 return { directory: resolved, prefix: '' }
71 }
72
73 // Split into directory and prefix
74 const directory = dirname(resolved)
75 const prefix = basename(partialPath)
76
77 return { directory, prefix }
78}
79
80/**
81 * Scans a directory and returns subdirectories

Callers 2

getDirectoryCompletionsFunction · 0.85
getPathCompletionsFunction · 0.85

Calls 2

getCwdFunction · 0.85
expandPathFunction · 0.85

Tested by

no test coverage detected