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

Function toRepoPath

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

Source from the content-addressed store, hash-verified

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

Callers 2

extractRepoLinksFunction · 0.85

Calls 1

stripTrailingPunctuationFunction · 0.85