MCPcopy Create free account
hub / github.com/allocnode/oh-my-sage / parseUrl

Method parseUrl

ref/gateway_client.js:287–295  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

285 }
286
287 static parseUrl(url) {
288 const match = url.match(/^(https?):\/\/([^/:]+)(?::(\d+))?((?:\/.*)?)/);
289 if (!match) throw new Error('Invalid URL');
290 const [, protocol, host, port, path] = match;
291 const wsProtocol = protocol === 'https' ? 'wss' : 'ws';
292 const wsPort = port || (protocol === 'https' ? '443' : '80');
293 const wsPath = (path || '').replace(/\/$/, '');
294 return `${wsProtocol}://${host}:${wsPort}${wsPath}/centrallinkws/`;
295 }
296
297 async connect(gatewayUrl) {
298 const url = GatewayClient.parseUrl(gatewayUrl);

Callers 1

connectMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected