fix: client browser cookies being unnecessarily deleted #274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
This pull request aims to fix the issue that has been bugging me as a user of Hoppscotch for a while. The problem lied with how cookies were handled, where any cookie specified in the Hoppscotch request would be deleted from my browser after the request finished. I disagree with it working like that, as I believe the extension should leave my browser as untouched as possible.
This was especially a problem when developing and testing one of my backends before I knew this behavior existed, and has cost me more time than I'd like to admit trying to figure out why my session cookies were disappearing lol.
The Fix
This modifies the way cookies are handled by the
removeRequestCookies
, by instead modifying it so pre-request we remember the state of the cookies before we change them. This lets theremoveRequestCookies
go through all modified cookies and return them to their original state as best as it can.Other Things
format
script to package.json to better make use of prettierNote: I have never touched the Chrome Extensions API before so apologies in advance for any oversights. I have not tested for Firefox.