(relayUrl: string)
| 86 | } |
| 87 | |
| 88 | export function deriveWorkspaceName(relayUrl: string): string { |
| 89 | try { |
| 90 | const url = new URL( |
| 91 | relayUrl.replace("ws://", "http://").replace("wss://", "https://"), |
| 92 | ); |
| 93 | const host = url.hostname; |
| 94 | if (host === "localhost" || host === "127.0.0.1") { |
| 95 | return "Local Dev"; |
| 96 | } |
| 97 | const parts = host.split("."); |
| 98 | // Detect staging environments (e.g. buzz-oss.stage.blox.sqprod.co) |
| 99 | if (parts.some((p) => p === "stage" || p === "staging")) { |
| 100 | return "Buzz (staging)"; |
| 101 | } |
| 102 | // Use the first subdomain segment or the domain itself |
| 103 | if (parts.length >= 2) { |
| 104 | return parts[0] === "relay" ? parts[1] : parts[0]; |
| 105 | } |
| 106 | return host; |
| 107 | } catch { |
| 108 | return "Workspace"; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | export function initFirstWorkspace( |
| 113 | relayUrl: string, |
no outgoing calls
no test coverage detected