MCPcopy Create free account
hub / github.com/cloudflare/computer / toWebSocketUrl

Function toWebSocketUrl

packages/computer/src/backends/test.ts:54–65  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

52}
53
54function 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
67function stripTrailingSlash(url: string): string {
68 return url.endsWith("/") ? url.slice(0, -1) : url;

Callers 1

connectMethod · 0.70

Calls 1

stripTrailingSlashFunction · 0.85

Tested by

no test coverage detected