Skip to content
This repository has been archived by the owner on Jan 24, 2020. It is now read-only.

Validate cookie properties in the set method, with more meaningful error messages #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dlajarretie
Copy link

According to Apple doc :

To successfully create a cookie, you must provide values for (at least) the NSHTTPCookiePath, NSHTTPCookieName, and NSHTTPCookieValue keys, and either the NSHTTPCookieOriginURL key or the NSHTTPCookieDomain key.

I have therefore added some checks to validate that the provided cookie properties match these requirements. This has the added benefit of allowing the creation of cookies when providing only the required properties.

Also took advantage of promises reject blocks to fail cleanly, with meaningful errors that can be caught directly in JS without crashing the native code.

@ravelab
Copy link

ravelab commented Dec 8, 2017

with this PR, is it possible to set a session-only cookie by not having expiration date?

@dlajarretie
Copy link
Author

It will be possible indeed (only for iOS though, I don't know if the Android implementation allows this already).

@safaiyeh
Copy link

I have forked the repo here: https://github.com/safaiyeh/react-native-cookie-store
We can create issues and PRs there to continue the development of the project.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants