-
Notifications
You must be signed in to change notification settings - Fork 64
Disable user-agent header when client options were not provided - Closes #696 #712
Conversation
@yatki This is failing on CI. |
ebe627b
to
b558322
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Two minor requests.
{ | ||
'User-Agent': getUserAgent(options.client), | ||
}, | ||
getUserAgent(options.client), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Object.assign
call combines various headers objects. User agent is on the wrong semantic level for this. The function as written doesn't just get the user agent, it gets a headers object which happens to only include the user agent (currently). We should either use the previous pattern or rename the function something like getClientHeaders
.
|
||
it('should not set User-Agent header when client options were not given', () => { | ||
apiClient = new APIClient(defaultNodes, { | ||
version: customHeaders.version, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually version
/customHeaders.version
doesn't make sense here. Could you remove it from the other test too?
What was the problem?
lisk-elements is throwing Refused to set unsafe header “User-Agent”warning when it's used in browsers.
How did I fix it?
I updated getUserAgent function to return empty object when clientOptions were not provided.
How to test it?
should not set User-Agent header when client options were not given
Review checklist
commit guidelines