Skip to content

Implement a `:force` option to delete cookies not present in the request

Rodrigo Muino Tomonari requested to merge github/fork/zavan/cookies-delete into main

Created by: zavan

Implement a :force option to delete cookies not present in the request.

Motivation / Background

This can be useful if you're trying to delete a cookie that has a path, from a different path, in which case it won't be present in the request and won't be deleted if the option is not passed.

Fixes #49746

Detail

This Pull Request adds a :force option to cookies.delete that skips checking if the cookie is present before marking it for removal.

Additional information

I initially tried simply removing the guard condition altogether (I gave my rationale for this in the linked Issue), but this broke some cookies.clear tests, so I though it should probably be an opt-in behavior through an option.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Merge request reports