@nxtedition/lib 23.3.6 → 23.3.8

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 +2 -2
  2. package/serializers.js +25 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.3.6",
3
+ "version": "23.3.8",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -66,7 +66,6 @@
66
66
  "@elastic/transport": "^8.9.3",
67
67
  "@nxtedition/nxt-undici": "^6.1.2",
68
68
  "@swc/wasm-web": "^1.10.16",
69
- "canvas": "^3.1.0",
70
69
  "content-type": "^1.0.5",
71
70
  "date-fns": "^4.1.0",
72
71
  "fast-querystring": "^1.1.1",
@@ -117,6 +116,7 @@
117
116
  "@elastic/elasticsearch": "^8.6.0",
118
117
  "@elastic/transport": "^8.3.1",
119
118
  "@nxtedition/deepstream.io-client-js": ">=14.1.0",
119
+ "canvas": "^3.1.0",
120
120
  "pino": ">=7.0.0",
121
121
  "rxjs": ">=6.0.0"
122
122
  }
package/serializers.js CHANGED
@@ -27,28 +27,40 @@ function getUrl(obj) {
27
27
  return undefined
28
28
  }
29
29
 
30
- if (obj.url?.href) {
31
- return obj.url.href
30
+ const { origin, path, hostname, protocol, port, url } = obj
31
+
32
+ const href = url?.href
33
+ if (typeof href === 'string' && href) {
34
+ return href
32
35
  }
33
36
 
34
- if (typeof obj.url === 'string') {
35
- return obj.url
37
+ if (typeof url === 'string' && url) {
38
+ return url
36
39
  }
37
40
 
38
- if (obj.origin) {
39
- const { origin, path } = obj
40
- if (path && path.startsWith('/') && origin.endsWith('/')) {
41
- return `${origin.slice(0, -1)}${path}`
42
- } else {
43
- return `${origin}${path || ''}`
41
+ if (origin && (!path || typeof path === 'string')) {
42
+ if (typeof origin === 'object') {
43
+ return `${origin.protocol || 'http:'}//${origin.hostname}:${origin.port || { 'http:': 80, 'https:': 443 }[origin.protocol]}${path || ''}`
44
+ }
45
+
46
+ if (typeof origin === 'string') {
47
+ if (path?.startsWith('/') && origin.endsWith('/')) {
48
+ return `${origin.slice(0, -1)}${path || ''}`
49
+ } else {
50
+ return `${origin}${path || ''}`
51
+ }
44
52
  }
45
53
  }
46
54
 
47
- if (obj.hostname) {
48
- return `${obj.protocol || 'http:'}//${obj.hostname}:${obj.port || { 'http:': 80, 'https:': 443 }[obj.protocol]}${obj.path || ''}`
55
+ if (typeof hostname === 'string') {
56
+ return `${protocol || 'http:'}//${hostname}:${port || { 'http:': 80, 'https:': 443 }[protocol || 'http:']}${path || ''}`
57
+ }
58
+
59
+ if (typeof path === 'string' && path) {
60
+ return path
49
61
  }
50
62
 
51
- return obj.path || obj.pathname
63
+ return null
52
64
  }
53
65
 
54
66
  function getTiming(obj) {