MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / toRelativePath

Function toRelativePath

src/utils/path.ts:120–124  ·  view source on GitHub ↗
(absolutePath: string)

Source from the content-addressed store, hash-verified

118 * @returns Relative path if under cwd, otherwise the original absolute path
119 */
120export function toRelativePath(absolutePath: string): string {
121 const relativePath = relative(getCwd(), absolutePath)
122 // If the relative path would go outside cwd (starts with ..), keep absolute
123 return relativePath.startsWith('..') ? absolutePath : relativePath
124}
125
126/**
127 * Gets the directory path for a given file or directory path.

Callers 3

path.test.tsFile · 0.90
callFunction · 0.85
UltraplanChoiceDialogFunction · 0.85

Calls 1

getCwdFunction · 0.85

Tested by

no test coverage detected