Skip to content
This repository was 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
dlajarretie wants to merge 1 commit intojoeferraro:masterfrom
dlajarretie:allow-partial-cookies
Open

Validate cookie properties in the set method, with more meaningful error messages#80
dlajarretie wants to merge 1 commit intojoeferraro:masterfrom
dlajarretie:allow-partial-cookies

Conversation

@dlajarretie
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Author

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

@safaiyeh
Copy link
Copy Markdown

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.

3 participants