@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.
@@ -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.startsWith("https")
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brokerize/client",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Client for the brokerize.com API",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/brokerize/client-js#readme",