(value: string | undefined)
| 41 | } |
| 42 | |
| 43 | export function normalizeServerOrigin(value: string | undefined): string { |
| 44 | const raw = value && value.trim() ? value : defaultServerOrigin(); |
| 45 | const url = new URL(raw); |
| 46 | url.pathname = url.pathname.replace(/\/v1\/?$/, '').replace(/\/$/, ''); |
| 47 | url.search = ''; |
| 48 | url.hash = ''; |
| 49 | return url.toString().replace(/\/$/, ''); |
| 50 | } |
| 51 | |
| 52 | /** Strip the scheme for a compact display origin: `http://127.0.0.1:58627` → `127.0.0.1:58627`. */ |
| 53 | function shortOrigin(origin: string): string { |
no test coverage detected