space-react-client 0.3.1 → 0.3.2

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/index.d.ts CHANGED
@@ -14129,7 +14129,7 @@ declare namespace React {
14129
14129
  *
14130
14130
  * @param callback A synchronous, void callback that will execute as a single, complete React commit.
14131
14131
  *
14132
- * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
14132
+ * @see {@link https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks}
14133
14133
  */
14134
14134
  // While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules.
14135
14135
  export function act(callback: () => VoidOrUndefinedOnly): void;
package/dist/index.js CHANGED
@@ -107,12 +107,14 @@ class TokenService {
107
107
  class SpaceClient {
108
108
  constructor(config) {
109
109
  this.userId = null;
110
- this.httpUrl = config.url.endsWith('/')
111
- ? config.url.slice(0, -1) + '/api/v1'
112
- : config.url + '/api/v1';
113
- this.wsUrl = config.url.replace(/^http/, 'ws') + '/events/pricings';
110
+ const normalizedUrl = config.url.endsWith('/') ? config.url.slice(0, -1) : config.url;
111
+ const parsedUrl = new URL(normalizedUrl);
112
+ const basePath = parsedUrl.pathname === '/' ? '' : parsedUrl.pathname.replace(/\/+$/, '');
113
+ const socketPath = `${basePath}/events`;
114
+ this.httpUrl = `${normalizedUrl}/api/v1`;
115
+ this.wsUrl = `${parsedUrl.protocol === 'https:' ? 'wss:' : 'ws:'}//${parsedUrl.host}${basePath}`;
114
116
  this.socketClient = io(this.wsUrl, {
115
- path: '/events',
117
+ path: socketPath,
116
118
  transports: ['websocket'],
117
119
  });
118
120
  this.pricingSocketNamespace = this.socketClient.io.socket('/pricings');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "space-react-client",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",