MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / toRequestyServiceUrl

Function toRequestyServiceUrl

src/shared/utils/requesty.ts:40–56  ·  view source on GitHub ↗
(baseUrl?: string | null, service: URLType = "router")

Source from the content-addressed store, hash-verified

38 * @returns A valid Requesty service URL
39 */
40export const toRequestyServiceUrl = (baseUrl?: string | null, service: URLType = "router"): string => {
41 // Handle null, undefined, empty string, or non-string values
42 const urlToUse = baseUrl && typeof baseUrl === "string" && baseUrl.trim() ? baseUrl.trim() : REQUESTY_BASE_URL
43
44 try {
45 // Validate the URL first
46 const validatedUrl = new URL(urlToUse).toString()
47 // Apply service type transformation
48 return replaceCname(validatedUrl, service)
49 } catch (error) {
50 // If the provided baseUrl is invalid, fall back to the default
51 if (baseUrl && baseUrl !== REQUESTY_BASE_URL) {
52 console.warn(`Invalid base URL "${baseUrl}", falling back to default`)
53 }
54 return replaceCname(REQUESTY_BASE_URL, service)
55 }
56}

Callers 6

requesty.spec.tsFile · 0.90
constructorMethod · 0.90
getRequestyModelsFunction · 0.90
RequestyBalanceDisplayFunction · 0.90
getApiKeyUrlFunction · 0.90
getRequestyKeyInfoFunction · 0.90

Calls 3

replaceCnameFunction · 0.85
toStringMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected