(value: string, label: string)
| 254 | } |
| 255 | |
| 256 | function normalizeBaseUrl(value: string, label: string): string { |
| 257 | try { |
| 258 | const parsed = new URL(value); |
| 259 | if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { |
| 260 | throw new Error('unsupported protocol'); |
| 261 | } |
| 262 | return parsed.toString().replace(/\/+$/, ''); |
| 263 | } catch (error) { |
| 264 | throw new AppError('INVALID_ARGS', `Invalid ${label}`, { [label]: value }, error); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | function normalizeToken(value: string, label: string): string { |
| 269 | const token = value.trim(); |
no outgoing calls
no test coverage detected