Skip to content

Commit

Permalink
chore: remove basic auth data from logs
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiahdz authored and Claudia Hernández committed Jun 30, 2020
1 parent 71ab0e7 commit 43a5d84
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion check-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ 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 = require('url')
const url = new URL(res.url)
urlStr = res.url.replace(url.password, '***')
} catch (er) {
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 43a5d84

Please sign in to comment.