Skip to content

Commit

Permalink
Merge pull request #221 from awaterma/GH-215-localhost-domain
Browse files Browse the repository at this point in the history
@GH-215 -- Tests that document localhost behavior when set as domain.
  • Loading branch information
ruoho-sfdc committed Oct 25, 2021
2 parents 39a9b1c + 826b0cf commit a6bd776
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/regression_test.js
Expand Up @@ -188,4 +188,47 @@ vows
}
}
})
.addBatch({
"setCookie with localhost (GH-215)": {
topic: function() {
const cookieJar = new CookieJar();
return cookieJar.setCookieSync("a=b; Domain=localhost", "http://localhost") // when domain set to 'localhost', will throw 'Error: Cookie has domain set to a public suffix'
},
works: function(err, c) {
// localhost as domain throws an error, cookie should not be defined
assert.instanceOf(err, Error)
assert.isUndefined(c)
}
}},
{
"setCookie with localhost (GH-215) (null domain)": {
topic: function() {
const cookieJar = new CookieJar();
return cookieJar.setCookieSync("a=b; Domain=", "http://localhost") // when domain set to 'localhost', will throw 'Error: Cookie has domain set to a public suffix'
},
works: function(c) {
assert.instanceOf(c, Cookie)
}
}},
{
"setCookie with localhost (localhost.local domain) (GH-215)": {
topic: function() {
const cookieJar = new CookieJar();
return cookieJar.setCookieSync("a=b; Domain=localhost.local", "http://localhost")
},
works: function(c) {
assert.instanceOf(c, Cookie)
}
}},
{
"setCookie with localhost (.localhost domain), (GH-215)": {
topic: function() {
const cookieJar = new CookieJar();
return cookieJar.setCookieSync("a=b; Domain=.localhost", "http://localhost")
},
works: function(c) {
assert.instanceOf(c, Cookie)
}
}
})
.export(module);

0 comments on commit a6bd776

Please sign in to comment.