Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding entry for Publicsuffix flag #17

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

Conversation

rchabra
Copy link

@rchabra rchabra commented Oct 28, 2020

For cordova having to add the PublicSuffix flag is annoying.

@@ -13069,20 +13069,15 @@ const { Cookie } = tough;
// it's possible to send these cookies to a domain someone could register after the fact, but
// 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