From 680f370f2d5c43936968e2d573373f7c419bd515 Mon Sep 17 00:00:00 2001 From: Alex Corn Date: Mon, 2 Sep 2024 22:18:21 -0400 Subject: [PATCH] Set cookies properly based on domain --- index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 214bff9..4144352 100644 --- a/index.js +++ b/index.js @@ -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"); + } }; /**