UNPKG

jsonrpc-websocket-client

Version:
23 lines (17 loc) 566 B
"use strict"; exports.__esModule = true; exports.default = void 0; var _url = require("url"); const PROTOCOL_RE = /^(?:(?:http|ws)(s?):\/\/)?(.+)$/; var _default = url => { if (typeof window !== "undefined") { const base = String(window.location); url = url ? (0, _url.resolve)(base, url) : base; } else if (!url) { throw new Error("cannot get current URL"); } const [, isSecure = "s", rest] = PROTOCOL_RE.exec(url); return ["ws", isSecure || "", "://", rest].join(""); }; exports.default = _default; //# sourceMappingURL=parse-url.js.map