-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: setting to toggle insomnia user-agent [INS-4107] #7640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: setting to toggle insomnia user-agent [INS-4107] #7640
Conversation
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.
https://github.com/Kong/insomnia/pull/7640/files#diff-0d876a97684cc6c868835d083785c52894f879ce84216e92bdb0a9876d4abcafR577
I think the setting should be passed like the other objects here instead of using models.settings.getOrCreate() inside this function
1d7eb64 to
3f83003
Compare
|
@gatzjames, I submitted a second pass, please review again |
95f91f4 to
ac97db7
Compare
gatzjames
left a comment
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.
Nice one!
Tested with many variations of enabling/disabling this and works great!
| // cleanup orphan app/version user-agent headers | ||
| const existingAppVersionUserAgent: RequestHeader | null = headers.find((h: any) => h.name.toLowerCase() === 'user-agent' && h.disabled === false && h.value.startsWith('insomnia')) || null; | ||
| if (existingAppVersionUserAgent) { | ||
| headers.splice(headers.indexOf(existingAppVersionUserAgent), 1); |
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.
splice is a mutating function, and tough to reason about.
Its better to use a pure function and name the output to make your code easier to read.
|
Let's update this in such a way that it does not add the default Insomnia The checkbox should be renamed with "Do not add Insomnia User-Agent for new requests". |
ac97db7 to
35d5f43
Compare
0db33fe to
4ce4d3c
Compare
This PR adds a new setting that allows disabling adding the default insomnia app version user-agent to new requests.
related to INS-4107