-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: master
Are you sure you want to change the base?
Conversation
@@ -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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
For cordova having to add the PublicSuffix flag is annoying.