Skip to content

Commit 43a5d84

Browse files
claudiahdzClaudia Hernández
authored and
Claudia Hernández
committed
chore: remove basic auth data from logs
1 parent 71ab0e7 commit 43a5d84

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

check-response.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,19 @@ function logRequest (method, res, startTime, opts) {
2929
const attempt = res.headers.get('x-fetch-attempts')
3030
const attemptStr = attempt && attempt > 1 ? ` attempt #${attempt}` : ''
3131
const cacheStr = res.headers.get('x-local-cache') ? ' (from cache)' : ''
32+
33+
let urlStr
34+
try {
35+
const URL = require('url')
36+
const url = new URL(res.url)
37+
urlStr = res.url.replace(url.password, '***')
38+
} catch (er) {
39+
urlStr = res.url
40+
}
41+
3242
opts.log.http(
3343
'fetch',
34-
`${method.toUpperCase()} ${res.status} ${res.url} ${elapsedTime}ms${attemptStr}${cacheStr}`
44+
`${method.toUpperCase()} ${res.status} ${urlStr} ${elapsedTime}ms${attemptStr}${cacheStr}`
3545
)
3646
}
3747

0 commit comments

Comments
 (0)