jsonrpc-websocket-client
Version:
JSON-RPC 2 over WebSocket
23 lines (17 loc) • 566 B
JavaScript
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
;