fix debug logging of undefined query params (#8540)
This commit is contained in:
@@ -222,7 +222,13 @@ class BaseService {
|
||||
let logUrl = url
|
||||
const logOptions = Object.assign({}, options)
|
||||
if ('searchParams' in options) {
|
||||
const params = new URLSearchParams(options.searchParams)
|
||||
const params = new URLSearchParams(
|
||||
Object.fromEntries(
|
||||
Object.entries(options.searchParams).filter(
|
||||
([k, v]) => v !== undefined
|
||||
)
|
||||
)
|
||||
)
|
||||
logUrl = `${url}?${params.toString()}`
|
||||
delete logOptions.searchParams
|
||||
}
|
||||
|
||||
@@ -440,14 +440,21 @@ describe('BaseService', function () {
|
||||
)
|
||||
|
||||
const url = 'some-url'
|
||||
const options = { headers: { Cookie: 'some-cookie' } }
|
||||
const options = {
|
||||
headers: { Cookie: 'some-cookie' },
|
||||
searchParams: { param1: 'foobar', param2: undefined },
|
||||
}
|
||||
await serviceInstance._request({ url, options })
|
||||
|
||||
expect(trace.logTrace).to.be.calledWithMatch(
|
||||
'fetch',
|
||||
sinon.match.string,
|
||||
'Request',
|
||||
`${url}\n${JSON.stringify(options, null, 2)}`
|
||||
`${url}?param1=foobar\n${JSON.stringify(
|
||||
{ headers: options.headers },
|
||||
null,
|
||||
2
|
||||
)}`
|
||||
)
|
||||
expect(trace.logTrace).to.be.calledWithMatch(
|
||||
'fetch',
|
||||
|
||||
Reference in New Issue
Block a user