Skip to content

Commit 680f370

Browse files
committed
Set cookies properly based on domain
1 parent e3172a1 commit 680f370

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,17 @@ SteamStore.prototype.setCookie = function(cookie) {
4242
this.steamID = new SteamID(cookie.match(/=(\d+)/)[1]);
4343
}
4444

45+
let requestCookie = Request.cookie(cookie);
46+
4547
let isSecure = !!cookieName.match(/(^steamMachineAuth|^steamLoginSecure$)/);
46-
this._jar.setCookie(Request.cookie(cookie), (isSecure ? "https://" : "http://") + "store.steampowered.com");
47-
this._jar.setCookie(Request.cookie(cookie), (isSecure ? "https://" : "http://") + "steamcommunity.com");
48+
let protocol = isSecure ? 'https' : 'http';
49+
50+
if (requestCookie.domain) {
51+
this._jar.setCookie(requestCookie.clone(), protocol + '://' + requestCookie.domain);
52+
} else {
53+
this._jar.setCookie(Request.cookie(cookie), protocol + "://store.steampowered.com");
54+
this._jar.setCookie(Request.cookie(cookie), protocol + "://steamcommunity.com");
55+
}
4856
};
4957

5058
/**

0 commit comments

Comments
 (0)