salesforce / tough-cookie

RFC6265 Cookies and CookieJar for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[RFC] Support for React Native

lb90 opened this issue · comments

commented

Hello, thanks for the good work!

I have been using this library on React Native (together with Axios) and so far it's been working ok!

I only had to remove some debug code using the utils module: lb90@b43b4e9.

Would you be interested in React Native support or do you specifically target just NodeJS? I can provide a PR if such a feature is welcome!

I'll take a look! We are definitely interested in supporting React; thank you for reaching out.

commented

Great!

I forgot to say that a polyfill for the NodeJS url module is also needed!

First I have tried porting tough-cookie to use the WHATWG url API instead of the legacy url API, that way I could use the great https://www.npmjs.com/package/react-native-url-polyfill. Unfortunately that didn't work out really well because the WHATWG API does not support relative URL's:

So in the end I opted for https://www.npmjs.com/package/url (from the github repo, seeing as the npm package was last updated 6 years ago!). Probably using https://www.npmjs.com/package/native-url + https://www.npmjs.com/package/react-native-url-polyfill is a best match!