MCPcopy
hub / github.com/github/docs / test

Function test

lib/get-redirect.js:190–200  ·  view source on GitHub ↗
(suffix)

Source from the content-addressed store, hash-verified

188// finds one string replacement that yields either a page or a redirect.
189function tryReplacements(prefix, suffix, { pages, redirects }) {
190 const test = (suffix) => {
191 // This is a generally broad search and replace and this particular
192 // replacement has never been present in api documentation only enterprise
193 // admin documentation, so we're excluding the REST api pages
194 if (suffix.includes('/rest')) {
195 return false
196 }
197 const candidateAsRedirect = prefix + suffix
198 const candidateAsURL = '/en' + candidateAsRedirect
199 return candidateAsRedirect in redirects || candidateAsURL in pages
200 }
201
202 let attempt = suffix.replace('/user', '/github')
203 if (test(attempt)) return attempt

Callers 15

tryReplacementsFunction · 0.85
browser.jsFile · 0.85
permalink.jsFile · 0.85
product-names.jsFile · 0.85
ghae-versioning.jsFile · 0.85
anchor-redirect.jsFile · 0.85
find-page.jsFile · 0.85
graphql.jsFile · 0.85
render-content.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected