MCPcopy
hub / github.com/nextauthjs/next-auth / parseUrl

Function parseUrl

src/lib/parse-url.ts:15–36  ·  view source on GitHub ↗
(url?: string)

Source from the content-addressed store, hash-verified

13
14/** Returns an `URL` like object to make requests/redirects from server-side */
15export default function parseUrl(url?: string): InternalUrl {
16 const defaultUrl = new URL("http://localhost:3000/api/auth")
17
18 if (url && !url.startsWith("http")) {
19 url = `https://${url}`
20 }
21
22 const _url = new URL(url ?? defaultUrl)
23 const path = (_url.pathname === "/" ? defaultUrl.pathname : _url.pathname)
24 // Remove trailing slash
25 .replace(/\/$/, "")
26
27 const base = `${_url.origin}${path}`
28
29 return {
30 origin: _url.origin,
31 host: _url.host,
32 path,
33 base,
34 toString: () => base,
35 }
36}

Callers 3

index.tsxFile · 0.85
initFunction · 0.85
handleMiddlewareFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…