MCPcopy Index your code
hub / github.com/simstudioai/sim / buildApiUrl

Function buildApiUrl

apps/sim/app/api/tools/sap_concur/proxy/route.ts:24–40  ·  view source on GitHub ↗
(geolocation: string, req: ProxyRequest)

Source from the content-addressed store, hash-verified

22type ProxyRequest = SapConcurProxyRequest
23
24function buildApiUrl(geolocation: string, req: ProxyRequest): string {
25 const base = geolocation.replace(/\/+$/, '')
26 const subPath = req.path.startsWith('/') ? req.path : `/${req.path}`
27 const url = `${base}${subPath}`
28
29 if (!req.query || Object.keys(req.query).length === 0) {
30 return url
31 }
32 const search = new URLSearchParams()
33 for (const [key, value] of Object.entries(req.query)) {
34 if (value === undefined || value === null) continue
35 search.append(key, String(value))
36 }
37 const queryString = search.toString()
38 if (!queryString) return url
39 return url.includes('?') ? `${url}&${queryString}` : `${url}?${queryString}`
40}
41
42interface Invocation {
43 status: number

Callers 1

callConcurFunction · 0.70

Calls 2

replaceMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected