Skip to content

Conversation

rchabra
Copy link

@rchabra rchabra commented Oct 28, 2020

For cordova having to add the PublicSuffix flag is annoying.

// for Heap, we need a parseable URI because internally we try to determine the right level to set
// a cookie, rather than having a known set of public suffix domains.
const FAKE_APP_URI = 'https://yourdomain.heap/';
const FAKE_APP_URI = 'https://' + window.location.host;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave yourdomain.heap - it's fine since we're adding the new flag. I'm also not 100% sure you always get window.location.host on all hybrid web apps, so wary of using it.

// original tests for this library included.
cookiejar.setCookieSync(Cookie.parse(cookie, {loose: true}), FAKE_APP_URI);
const store = new WebStorageCookieStore(localStorage);
const cookiejar = new tough.CookieJar(store);
Copy link

@radiofreejohn radiofreejohn Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 13076 is redundant, and can be removed

cookiejar.setCookieSync(Cookie.parse(cookie, {loose: true}), FAKE_APP_URI);
const store = new WebStorageCookieStore(localStorage);
const cookiejar = new tough.CookieJar(store);
const cookiejar = new tough.CookieJar(store, false); //false here sets the rejectPublicSuffix flag

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument that tough.CookieJar is expecting is an object with the flag names and values, like:

tough.CookieJar(store, {rejectPublicSuffix: false}); -- which is also nice because it's self documenting, unless you want to explain that we need that flag for Cordova compatibility.

const cookiejar = new tough.CookieJar(store, false); //false here sets the rejectPublicSuffix flag
Object.defineProperty(document, "cookie", {
get() {
return cookiejar.getCookieStringSync(FAKE_APP_URI);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think formatting got broken here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants