Skip to content

Commit

Permalink
chore: remove auth data from logs (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudia Hernández authored Jun 30, 2020
1 parent 09e540b commit 18bf9b9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion check-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,18 @@ function logRequest (method, res, startTime, opts) {
const attempt = res.headers.get('x-fetch-attempts')
const attemptStr = attempt && attempt > 1 ? ` attempt #${attempt}` : ''
const cacheStr = res.headers.get('x-local-cache') ? ' (from cache)' : ''

let urlStr
try {
const url = new URL(res.url)
urlStr = res.url.replace(url.password, '***')
} catch {
urlStr = res.url
}

opts.log.http(
'fetch',
`${method.toUpperCase()} ${res.status} ${res.url} ${elapsedTime}ms${attemptStr}${cacheStr}`
`${method.toUpperCase()} ${res.status} ${urlStr} ${elapsedTime}ms${attemptStr}${cacheStr}`
)
}

Expand Down

0 comments on commit 18bf9b9

Please sign in to comment.