MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getUsableOrigin

Function getUsableOrigin

web/src/app/api/auth/cli/code/_origin.ts:15–25  ·  view source on GitHub ↗
(url: string, allowLocalhost: boolean)

Source from the content-addressed store, hash-verified

13}
14
15function getUsableOrigin(url: string, allowLocalhost: boolean) {
16 try {
17 const parsedUrl = new URL(url)
18 if (!allowLocalhost && isLocalhost(parsedUrl.hostname)) {
19 return null
20 }
21 return parsedUrl.origin
22 } catch {
23 return null
24 }
25}
26
27function isLocalhost(hostname: string) {
28 const normalizedHostname = hostname.replace(/^\[|\]$/g, '')

Callers 1

getLoginUrlOriginFunction · 0.70

Calls 1

isLocalhostFunction · 0.70

Tested by

no test coverage detected