Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions dist/electron-cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.


(function(document) {
const store = new WebStorageCookieStore(localStorage);

const cookiejar = new tough.CookieJar(store);
Object.defineProperty(document, "cookie", {
get() {
return cookiejar.getCookieStringSync(FAKE_APP_URI);
},
set(cookie) {
// loose: true lets us accept cookies with key and no value, which the
// 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

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.

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

}
});
})(document);
Expand Down