From ea0ea0ce42a81563a92cb8c00a7d876df6235754 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Thu, 25 Aug 2022 10:11:55 -0300 Subject: [PATCH] fix: allow set cookies with localhost Adding more tests to cover the breaking use cases noted in #246. e.g.;. * `new CookieJar().setCookieSync("settingThisShouldPass=true; Domain=localhost; Path=/;", "http://localhost")` Also modifies the assertion for a test introduced in #221 that may be incorrect. --- lib/pubsuffix-psl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pubsuffix-psl.js b/lib/pubsuffix-psl.js index bf416511..83398555 100644 --- a/lib/pubsuffix-psl.js +++ b/lib/pubsuffix-psl.js @@ -60,7 +60,7 @@ function getPublicSuffix(domain, options = {}) { if (!ignoreError && SPECIAL_USE_DOMAINS.includes(topLevelDomain)) { if (allowSpecialUseDomain) { - return ""; + return topLevelDomain; } throw new Error( `Cookie has domain set to the public suffix "${topLevelDomain}" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.`