@brokerize/client 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authorizedApiContext.js +14 -3
- package/package.json +1 -1
|
@@ -402,9 +402,7 @@ export class AuthorizedApiContext {
|
|
|
402
402
|
}
|
|
403
403
|
_initInternalWebSocketClient() {
|
|
404
404
|
const basePath = this._cfg.basePath || "https://api-preview.brokerize.com";
|
|
405
|
-
const websocketPath = (basePath
|
|
406
|
-
? "wss://" + basePath.substring(8)
|
|
407
|
-
: "ws://" + basePath.substring(7)) + "/websocket";
|
|
405
|
+
const websocketPath = getWebSocketURLByBasePath(basePath);
|
|
408
406
|
if (!this._cfg.createWebSocket) {
|
|
409
407
|
throw new Error("createWebSocket not provided. This should not happen as there should be a default implementation.");
|
|
410
408
|
}
|
|
@@ -434,3 +432,16 @@ export class AuthorizedApiContext {
|
|
|
434
432
|
};
|
|
435
433
|
}
|
|
436
434
|
}
|
|
435
|
+
function getWebSocketURLByBasePath(basePath) {
|
|
436
|
+
const SUFFIX = "/websocket";
|
|
437
|
+
if (basePath.startsWith("https")) {
|
|
438
|
+
return "wss://" + basePath.substring(8) + SUFFIX;
|
|
439
|
+
}
|
|
440
|
+
else if (basePath.startsWith("http")) {
|
|
441
|
+
return "ws://" + basePath.substring(7) + SUFFIX;
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
// might be a relative path
|
|
445
|
+
return basePath + SUFFIX;
|
|
446
|
+
}
|
|
447
|
+
}
|