Skip to content

Commit 110032b

Browse files
committed
fix: correct password redaction
Avoids setting '***' at the start of urls witout passwords, avoids hazard if a password is 'https:'.
1 parent 2275f55 commit 110032b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

check-response.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ function logRequest (method, res, startTime, opts) {
3232

3333
let urlStr
3434
try {
35-
const { URL } = require('url')
35+
const URL = require('url').URL
3636
const url = new URL(res.url)
37-
urlStr = res.url.replace(url.password, '***')
37+
if (url.password) {
38+
url.password = '***'
39+
}
40+
urlStr = url.toString()
3841
} catch (er) {
3942
urlStr = res.url
4043
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"scripts": {
1414
"prerelease": "npm t",
1515
"postrelease": "npm publish && git push --follow-tags",
16-
"pretest": "standard",
16+
"posttest": "standard",
1717
"release": "standard-version -s",
1818
"test": "tap -J --coverage test/*.js",
1919
"update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",

0 commit comments

Comments
 (0)