azify-logger 1.0.54-test-2 → 1.0.54-test-3
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/package.json +1 -1
- package/register-http-client-early.js +25 -7
- package/register.js +9 -2
package/package.json
CHANGED
|
@@ -28,13 +28,29 @@ try {
|
|
|
28
28
|
const MAX_EARLY_LOG_QUEUE = 2000
|
|
29
29
|
const earlyLogQueue = []
|
|
30
30
|
|
|
31
|
+
function normalizePathEarly(p) {
|
|
32
|
+
if (!p) return '/'
|
|
33
|
+
const trimmed = String(p).replace(/\/+$/, '')
|
|
34
|
+
return trimmed === '' ? '/' : trimmed
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Ignora esquema (http vs https): undici muitas vezes resolve como https e AZIFY_LOGGER_URL é http em dev. */
|
|
31
38
|
function isLoggerUrl(urlStr) {
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const loggerUrlRaw = process.env.AZIFY_LOGGER_URL || 'http://localhost:3001/log'
|
|
40
|
+
if (typeof urlStr !== 'string' || !urlStr.trim()) return false
|
|
41
|
+
try {
|
|
42
|
+
const base = new URL(String(loggerUrlRaw).trim())
|
|
43
|
+
const cand = new URL(String(urlStr).trim())
|
|
44
|
+
if (base.hostname.toLowerCase() !== cand.hostname.toLowerCase()) return false
|
|
45
|
+
const portBase = base.port || (base.protocol === 'https:' ? '443' : '80')
|
|
46
|
+
const portCand = cand.port || (cand.protocol === 'https:' ? '443' : '80')
|
|
47
|
+
if (String(portBase) !== String(portCand)) return false
|
|
48
|
+
const lp = normalizePathEarly(base.pathname)
|
|
49
|
+
const tp = normalizePathEarly(cand.pathname)
|
|
50
|
+
return tp === lp || tp.startsWith(lp + '/')
|
|
51
|
+
} catch (_) {
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
38
54
|
}
|
|
39
55
|
|
|
40
56
|
/** undici.request(url, opts) / request(opts) — muitas chamadas não trazem origin; path pode ser URL absoluta ou só path + hostname. */
|
|
@@ -53,7 +69,9 @@ try {
|
|
|
53
69
|
if (opts && (opts.hostname || opts.host)) {
|
|
54
70
|
const h = String(opts.hostname || String(opts.host || '').split(':')[0]).trim()
|
|
55
71
|
if (h) {
|
|
56
|
-
const
|
|
72
|
+
const hl = h.toLowerCase()
|
|
73
|
+
const isLocal = hl === 'localhost' || hl === '127.0.0.1' || hl === '::1'
|
|
74
|
+
const proto = (opts.protocol && String(opts.protocol).replace(/:$/, '')) || (isLocal ? 'http' : 'https')
|
|
57
75
|
const pnum = opts.port != null && opts.port !== '' ? Number(opts.port) : NaN
|
|
58
76
|
const port = !Number.isNaN(pnum) && pnum !== 80 && pnum !== 443 ? ':' + pnum : ''
|
|
59
77
|
const p = opts.path != null ? String(opts.path) : '/'
|
package/register.js
CHANGED
|
@@ -377,9 +377,16 @@ try {
|
|
|
377
377
|
|
|
378
378
|
try {
|
|
379
379
|
const target = new URL(candidate, normalizedLoggerOrigin)
|
|
380
|
-
|
|
380
|
+
if (loggerEndpoint.hostname.toLowerCase() !== target.hostname.toLowerCase()) {
|
|
381
|
+
return false
|
|
382
|
+
}
|
|
383
|
+
const portLogger = loggerEndpoint.port || (loggerEndpoint.protocol === 'https:' ? '443' : '80')
|
|
384
|
+
const portTarget = target.port || (target.protocol === 'https:' ? '443' : '80')
|
|
385
|
+
if (String(portLogger) !== String(portTarget)) {
|
|
386
|
+
return false
|
|
387
|
+
}
|
|
381
388
|
const targetPath = normalizePath(target.pathname)
|
|
382
|
-
return
|
|
389
|
+
return targetPath === normalizedLoggerPath || targetPath.startsWith(normalizedLoggerPath + '/')
|
|
383
390
|
} catch (_) {
|
|
384
391
|
if (typeof candidate === 'string') {
|
|
385
392
|
const relativePath = normalizePath(candidate)
|