MCPcopy Index your code
hub / github.com/desktop/desktop / getHTMLURL

Function getHTMLURL

app/src/lib/api.ts:2282–2313  ·  view source on GitHub ↗
(endpoint: string)

Source from the content-addressed store, hash-verified

2280 * http://github.mycompany.com/api -> http://github.mycompany.com/
2281 */
2282export function getHTMLURL(endpoint: string): string {
2283 if (envHTMLURL !== undefined) {
2284 return envHTMLURL
2285 }
2286
2287 // In the case of GitHub.com, the HTML site lives on the parent domain.
2288 // E.g., https://api.github.com -> https://github.com
2289 //
2290 // Whereas with Enterprise, it lives on the same domain but without the
2291 // API path:
2292 // E.g., https://github.mycompany.com/api/v3 -> https://github.mycompany.com
2293 //
2294 // We need to normalize them.
2295 if (endpoint === getDotComAPIEndpoint() && !envEndpoint) {
2296 return 'https://github.com'
2297 } else {
2298 if (isGHE(endpoint)) {
2299 const url = new window.URL(endpoint)
2300
2301 url.pathname = '/'
2302
2303 if (url.hostname.startsWith('api.')) {
2304 url.hostname = url.hostname.replace(/^api\./, '')
2305 }
2306
2307 return url.toString()
2308 }
2309
2310 const parsed = URL.parse(endpoint)
2311 return `${parsed.protocol}//${parsed.hostname}`
2312 }
2313}
2314
2315/**
2316 * Get the API URL for an HTML URL. For example:

Callers 15

matchGitHubRepositoryFunction · 0.90
scanForMentionMethod · 0.90
findAccountForRemoteURLFunction · 0.90
issueUrlFunction · 0.90
createLinkElementMethod · 0.90
createLinkElementMethod · 0.90
createLinkElementMethod · 0.90
commitMentionUrlMethod · 0.90

Calls 4

isGHEFunction · 0.90
getDotComAPIEndpointFunction · 0.85
parseMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected