Skip to content

Commit

Permalink
chore: remove auth data from logs
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiahdz committed Jun 30, 2020
1 parent 09e540b commit a36abbd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion check-response.js
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 a36abbd

Please sign in to comment.