MCPcopy Index your code
hub / github.com/bugy/script-server / getWebsocketUrl

Function getWebsocketUrl

web-src/src/common/utils/common.js:305–326  ·  view source on GitHub ↗
(relativePath)

Source from the content-addressed store, hash-verified

303}
304
305export function getWebsocketUrl(relativePath) {
306 var location = window.location;
307
308 var https = location.protocol.toLowerCase() === 'https:';
309 var wsProtocol = https ? 'wss' : 'ws';
310 var hostUrl = wsProtocol + '://' + location.host;
311
312 var dir = getUrlDir();
313 if (dir) {
314 hostUrl += dir;
315 }
316
317 if (isEmptyString(relativePath)) {
318 return hostUrl;
319 }
320
321 if (!hostUrl.endsWith('/')) {
322 hostUrl += '/';
323 }
324
325 return hostUrl + relativePath;
326}
327
328export function isWebsocketClosed(websocket) {
329 return ((websocket.readyState === 2) || (websocket.readyState === 3));

Callers 2

ReactiveWebSocketFunction · 0.90
attachToWebsocketFunction · 0.90

Calls 2

getUrlDirFunction · 0.85
isEmptyStringFunction · 0.85

Tested by

no test coverage detected