MCPcopy
hub / github.com/vercel/next.js / getFullUrl

Function getFullUrl

test/lib/next-test-utils.ts:133–157  ·  view source on GitHub ↗
(
  appPortOrUrl: string | number,
  url?: string,
  hostname?: string
)

Source from the content-addressed store, hash-verified

131}
132
133export function getFullUrl(
134 appPortOrUrl: string | number,
135 url?: string,
136 hostname?: string
137) {
138 let fullUrl =
139 typeof appPortOrUrl === 'string' && appPortOrUrl.startsWith('http')
140 ? appPortOrUrl
141 : `http://${hostname ? hostname : 'localhost'}:${appPortOrUrl}${url}`
142
143 if (typeof appPortOrUrl === 'string' && url) {
144 const parsedUrl = new URL(fullUrl)
145 const parsedPathQuery = new URL(url, fullUrl)
146
147 parsedUrl.hash = parsedPathQuery.hash
148 parsedUrl.search = parsedPathQuery.search
149 parsedUrl.pathname = parsedPathQuery.pathname
150
151 if (hostname && parsedUrl.hostname === 'localhost') {
152 parsedUrl.hostname = hostname
153 }
154 fullUrl = parsedUrl.toString()
155 }
156 return fullUrl
157}
158
159/**
160 * Appends the querystring to the url

Callers 5

launchStandaloneSessionFunction · 0.90
webdriverFunction · 0.90
getFetchUrlFunction · 0.70
fetchViaHTTPFunction · 0.70

Calls 2

startsWithMethod · 0.80
toStringMethod · 0.45

Tested by 1

launchStandaloneSessionFunction · 0.72