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

Function repoLinkPattern

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

Source from the content-addressed store, hash-verified

242// at whitespace, a closing paren (markdown link syntax), a backtick, or a
243// quote; trailing prose punctuation is trimmed separately.
244function repoLinkPattern() {
245 // The slug is interpolated into a regex source, so escape every character
246 // that would otherwise be read as a metacharacter. Backslash has to come
247 // first in the class so it is escaped before it can pair with a later
248 // replacement.
249 const slug = REPO_SLUG.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
250 return new RegExp(
251 "(?:https?:\\/\\/)?(?:" +
252 `raw\\.githubusercontent\\.com\\/${slug}\\/main\\/` +
253 "|" +
254 `github\\.com\\/${slug}\\/(blob|tree)\\/main\\/` +
255 ")([^\\s)\\]`\"'<>]+)",
256 "g"
257 );
258}
259
260// Trailing characters that belong to the surrounding sentence, not the URL.
261// The escaped codepoints are the CJK punctuation the translated docs end

Callers 1

extractRepoLinksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected