(input: string)
| 52 | } |
| 53 | |
| 54 | function toWebSocketUrl(input: string): string { |
| 55 | if (input.startsWith("ws://") || input.startsWith("wss://")) { |
| 56 | return stripTrailingSlash(input); |
| 57 | } |
| 58 | if (input.startsWith("http://")) { |
| 59 | return stripTrailingSlash(`ws://${input.slice("http://".length)}`); |
| 60 | } |
| 61 | if (input.startsWith("https://")) { |
| 62 | return stripTrailingSlash(`wss://${input.slice("https://".length)}`); |
| 63 | } |
| 64 | throw new Error(`TestBackend: unsupported URL scheme in ${input}`); |
| 65 | } |
| 66 | |
| 67 | function stripTrailingSlash(url: string): string { |
| 68 | return url.endsWith("/") ? url.slice(0, -1) : url; |
no test coverage detected