When using option rejectPublicSuffixes: true (the default), trying to set a cookie with Domain=localhost throws the error Cookie has domain set to a public suffix, which I believe is incorrect.
How to reproduce
Run the following code with the latest master of tough-cookie (commit 1b25269)
const { CookieJar } = require("../lib/cookie");
const cookieJar = new CookieJar();
cookieJar.setCookieSync("a=b; Domain=localhost", "http://localhost") // throws 'Error: Cookie has domain set to a public suffix'
Expected result
I can set cookies with Domain=localhost without an error.
Workaround
Turning off the rejectPublicSuffixes option when creating the CookieJar causes the cookie to be set without errors, as expected.
When using option
rejectPublicSuffixes: true(the default), trying to set a cookie withDomain=localhostthrows the errorCookie has domain set to a public suffix, which I believe is incorrect.How to reproduce
Run the following code with the latest master of tough-cookie (commit 1b25269)
Expected result
I can set cookies with
Domain=localhostwithout an error.Workaround
Turning off the
rejectPublicSuffixesoption when creating theCookieJarcauses the cookie to be set without errors, as expected.