@carecard/telemetry 3.19.0 → 3.21.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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/instrumentations.js +16 -3
package/README.md
CHANGED
package/package.json
CHANGED
package/src/instrumentations.js
CHANGED
|
@@ -32,11 +32,24 @@ function isRoutineRequest(request) {
|
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// Pattern: Normalizer - produces the bracketed URL host form for DNS, IPv4, and IPv6 inputs.
|
|
36
|
+
function normalizeRequestHost(requestHost) {
|
|
37
|
+
const host = String(requestHost || '')
|
|
38
|
+
.replace(/^https?:\/\//, '')
|
|
39
|
+
.split('/')[0];
|
|
40
|
+
if (host.startsWith('[') || host.split(':').length <= 2) {
|
|
41
|
+
return host;
|
|
42
|
+
}
|
|
43
|
+
return `[${host}]`;
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
// Pattern: Normalizer - creates the endpoint host form without duplicating a supplied port.
|
|
36
47
|
function requestHostWithPort(request) {
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
48
|
+
const normalizedHost = normalizeRequestHost(request.hostname || request.host || request.origin);
|
|
49
|
+
const hasExplicitPort = normalizedHost.startsWith('[')
|
|
50
|
+
? normalizedHost.includes(']:')
|
|
51
|
+
: normalizedHost.includes(':');
|
|
52
|
+
if (!request.port || hasExplicitPort) {
|
|
40
53
|
return normalizedHost;
|
|
41
54
|
}
|
|
42
55
|
return `${normalizedHost}:${request.port}`;
|