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

Function repoLinkPattern

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

Source from the content-addressed store, hash-verified

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