MCPcopy
hub / github.com/blitz-js/blitz / getFullUrl

Function getFullUrl

integration-tests/utils/next-test-utils.ts:71–90  ·  view source on GitHub ↗
(appPortOrUrl: string | number, url: string, hostname?: string)

Source from the content-addressed store, hash-verified

69}
70
71export function getFullUrl(appPortOrUrl: string | number, url: string, hostname?: string) {
72 let fullUrl =
73 typeof appPortOrUrl === "string" && appPortOrUrl.startsWith("http")
74 ? appPortOrUrl
75 : `http://${hostname ? hostname : "localhost"}:${appPortOrUrl}${url}`
76
77 if (typeof appPortOrUrl === "string" && url) {
78 const parsedUrl = new URL(fullUrl)
79 const parsedPathQuery = new URL(url, fullUrl)
80
81 parsedUrl.search = parsedPathQuery.search
82 parsedUrl.pathname = parsedPathQuery.pathname
83
84 if (hostname && parsedUrl.hostname === "localhost") {
85 parsedUrl.hostname = hostname
86 }
87 fullUrl = parsedUrl.toString()
88 }
89 return fullUrl
90}
91
92export function renderViaAPI(app, pathname, query) {
93 const url = `${pathname}${query ? `?${qs.stringify(query)}` : ""}`

Callers 2

webdriverFunction · 0.90
fetchViaHTTPFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected