@noatgnu/cupcake-core 1.3.5 → 1.3.7

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.
@@ -1204,19 +1204,22 @@ class WebSocketService {
1204
1204
  this.setupBrowserResourceHandling();
1205
1205
  }
1206
1206
  getWebSocketUrl() {
1207
+ const endpoint = this.config?.endpoint || 'ccc/notifications';
1208
+ if (this.config_token.websocketUrl) {
1209
+ const wsUrl = this.config_token.websocketUrl.replace(/\/$/, '');
1210
+ return `${wsUrl}/${endpoint}/`;
1211
+ }
1207
1212
  const apiUrl = this.config_token.apiUrl;
1208
1213
  try {
1209
1214
  const url = new URL(apiUrl);
1210
1215
  const protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
1211
1216
  const host = url.host;
1212
- const endpoint = this.config?.endpoint || 'ccc/notifications';
1213
1217
  return `${protocol}//${host}/ws/${endpoint}/`;
1214
1218
  }
1215
1219
  catch (error) {
1216
1220
  console.error('Invalid API URL in cupcake config:', apiUrl);
1217
1221
  const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
1218
1222
  const host = window.location.host;
1219
- const endpoint = this.config?.endpoint || 'ccc/notifications';
1220
1223
  return `${protocol}//${host}/ws/${endpoint}/`;
1221
1224
  }
1222
1225
  }