Skip to content

Commit

Permalink
Set cookies properly based on domain
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorMcKay committed Sep 3, 2024
1 parent e3172a1 commit 680f370
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ SteamStore.prototype.setCookie = function(cookie) {
this.steamID = new SteamID(cookie.match(/=(\d+)/)[1]);
}

let requestCookie = Request.cookie(cookie);

let isSecure = !!cookieName.match(/(^steamMachineAuth|^steamLoginSecure$)/);
this._jar.setCookie(Request.cookie(cookie), (isSecure ? "https://" : "http://") + "store.steampowered.com");
this._jar.setCookie(Request.cookie(cookie), (isSecure ? "https://" : "http://") + "steamcommunity.com");
let protocol = isSecure ? 'https' : 'http';

if (requestCookie.domain) {
this._jar.setCookie(requestCookie.clone(), protocol + '://' + requestCookie.domain);
} else {
this._jar.setCookie(Request.cookie(cookie), protocol + "://store.steampowered.com");
this._jar.setCookie(Request.cookie(cookie), protocol + "://steamcommunity.com");
}
};

/**
Expand Down

0 comments on commit 680f370

Please sign in to comment.