@ircam/comote-helpers 0.1.1 → 0.2.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/qrcode.js +19 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ircam/comote-helpers",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Server component & utilities for the CoMo.te application",
5
5
  "authors": [
6
6
  "Benjamin.Matuszewski@ircam.fr",
package/qrcode.js CHANGED
@@ -25,15 +25,30 @@ function formatConfigToLink(config) {
25
25
 
26
26
  if (config.ws) {
27
27
  const {
28
+ protocol,
28
29
  hostname,
29
- port
30
- } = config.ws;
30
+ port,
31
+ pathname
32
+ } = config.ws; // build valid url
33
+ // only hostname is required
31
34
 
32
- if (!hostname || !Number.isInteger(port)) {
35
+ if (!hostname) {
33
36
  throw new Error(`Invalid WebSocket config: ${config.ws}`);
34
37
  }
35
38
 
36
- query.push(`ws-url=ws://${hostname}:${port}`);
39
+ let url = `ws-url=`;
40
+ url += protocol == 'ws' || protocol == 'wss' ? `${protocol}://` : `ws://`;
41
+ url += hostname;
42
+
43
+ if (port) {
44
+ url += `:${port}`;
45
+ }
46
+
47
+ if (pathname) {
48
+ url += pathname;
49
+ }
50
+
51
+ query.push(url); // autostart
37
52
 
38
53
  if (config.ws.autostart === true) {
39
54
  query.push(`ws-enable=1`);