MCPcopy Create free account
hub / github.com/anomalyco/opencode / stripPrefix

Function stripPrefix

packages/opencode/src/config/entry-name.ts:8–13  ·  view source on GitHub ↗
(relativePath: string, prefixes: string[])

Source from the content-addressed store, hash-verified

6// to mis-key agents whose home/parent segments coincidentally contained one of
7// the prefix names (see #25713).
8function stripPrefix(relativePath: string, prefixes: string[]) {
9 const normalized = relativePath.replaceAll("\\", "/")
10 for (const prefix of prefixes) {
11 if (normalized.startsWith(prefix)) return normalized.slice(prefix.length)
12 }
13}
14
15export function configEntryNameFromPath(relativePath: string, prefixes: string[]) {
16 const candidate = stripPrefix(relativePath, prefixes) ?? path.basename(relativePath)

Callers 1

configEntryNameFromPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected