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.
What's wrong?
Important
Currently, there is no way to set a cookie without a
.
prefix which can lead to buggy behavior with some sites.This PR fixes that, by allowing cookies to be set without a domain and instead inferred from the url.
Domain
is allowed as an optional value in the Android CookieManager docs when setting a cookie.Example usage of
Cookiemanager.set
which should result in a.
domain prefix vs not:This proposed change removes
topLevelDomain
as a fallback value whendomain
is missing. This indirectly allows setting a cookie without a.
prefix in android, more info about the leading dot and how the dot infers hostOnly.Why is this an issue?
Important
Currently, a cookie
Foo
can be duplicated on android because of the.
domain prefix and there is no way to set a domain without a.
prefix via the react-native-cookies libraryFor me, this caused a re-direct loop in one of our webviews because the site was only looking at the original cookie value and not the duplicated cookie value which was set by the HTTP response. I imagine the buggy behavior could manifest in different ways as well.
How to reproduce?
Foo=Bar
cookie viaCookieManager.set()
Foo=FooBar
cookie via Set-Cookie response header in aWebview
on android.Additionally, you can quickly verify that this is possible by simply creating two cookies in chrome dev tools.