MCPcopy Create free account
hub / github.com/alibaba/open-code-review / toRepoPath

Function toRepoPath

scripts/github-actions/check-plugin-contract.js:274–285  ·  view source on GitHub ↗
(rawPath)

Source from the content-addressed store, hash-verified

272// Reduce a URL path run to the repo-relative path it addresses: drop any
273// fragment or query, trim prose punctuation, and percent-decode.
274function toRepoPath(rawPath) {
275 let p = rawPath.split("#")[0].split("?")[0];
276 p = stripTrailingPunctuation(p);
277 p = p.replace(/\/+$/, ""); // a trailing slash is directory notation, not a name
278 if (!p) return null;
279 try {
280 p = decodeURIComponent(p);
281 } catch (e) {
282 /* leave the raw form; a malformed escape will fail the existence check */
283 }
284 return p;
285}
286
287// Extract every in-repo link from one file's content.
288// Returns [{ repoPath, kind: "file"|"tree", line, raw }], skipping lines that

Callers 2

extractRepoLinksFunction · 0.85

Calls 1

stripTrailingPunctuationFunction · 0.85