Skip to content

Commit 18bf9b9

Browse files
author
Claudia Hernández
authored
chore: remove auth data from logs (#29)
1 parent 09e540b commit 18bf9b9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Diff for: check-response.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@ function logRequest (method, res, startTime, opts) {
3030
const attempt = res.headers.get('x-fetch-attempts')
3131
const attemptStr = attempt && attempt > 1 ? ` attempt #${attempt}` : ''
3232
const cacheStr = res.headers.get('x-local-cache') ? ' (from cache)' : ''
33+
34+
let urlStr
35+
try {
36+
const url = new URL(res.url)
37+
urlStr = res.url.replace(url.password, '***')
38+
} catch {
39+
urlStr = res.url
40+
}
41+
3342
opts.log.http(
3443
'fetch',
35-
`${method.toUpperCase()} ${res.status} ${res.url} ${elapsedTime}ms${attemptStr}${cacheStr}`
44+
`${method.toUpperCase()} ${res.status} ${urlStr} ${elapsedTime}ms${attemptStr}${cacheStr}`
3645
)
3746
}
3847

0 commit comments

Comments
 (0)