| 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. |
| 272 | function 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 |