MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / isUsableSourcePath

Function isUsableSourcePath

src/ui-server/security.ts:270–274  ·  view source on GitHub ↗

* Whether a project-relative source path is one we would read at all: no raw * control byte (NUL truncates a path in some syscalls), and on Windows no * backslash, a separator there that indexed paths never use. Nothing is * decoded: a `%` in the path is part of a file name.

(relativePath: string)

Source from the content-addressed store, hash-verified

268 * decoded: a `%` in the path is part of a file name.
269 */
270function isUsableSourcePath(relativePath: string): boolean {
271 // eslint-disable-next-line no-control-regex -- rejecting raw control bytes IS the point
272 if (/[\x00-\x1f\x7f]/.test(relativePath)) return false;
273 return !(process.platform === 'win32' && relativePath.includes('\\'));
274}
275
276/**
277 * Resolve a project-relative source path to an absolute path that is safe to

Callers 1

resolveProjectFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected