GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode/packages/opencode/src/config/entry-name.ts at dev · githubhjs/opencode Expand file tree/ Copy pathentry-name.tsMore file actions 19 lines (17 loc) · 897 Bytes / Copy pathentry-name.tsFile metadata and controls19 lines (17 loc) · 897 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import path from "path" // Strips a known prefix from an already-relative path. Callers should pass the // path relative to the directory they scanned (e.g. `path.relative(dir, item)`) // so the prefix match is anchored. Matching anywhere in an absolute path used // to mis-key agents whose home/parent segments coincidentally contained one of // the prefix names (see #25713). function stripPrefix(relativePath: string, prefixes: string[]) { const normalized = relativePath.replaceAll("\\", "/") for (const prefix of prefixes) { if (normalized.startsWith(prefix)) return normalized.slice(prefix.length) } } export function configEntryNameFromPath(relativePath: string, prefixes: string[]) { const candidate = stripPrefix(relativePath, prefixes) ?? path.basename(relativePath) const ext = path.extname(candidate) return ext.length ? candidate.slice(0, -ext.length) : candidate } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |