(geolocation: string, req: ProxyRequest)
| 22 | type ProxyRequest = SapConcurProxyRequest |
| 23 | |
| 24 | function 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 | |
| 42 | interface Invocation { |
| 43 | status: number |
no test coverage detected