Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'assaf'

  • Loading branch information...
commit 61c76db30b8dbb6c22e891c5d2a470e6b2d4cde1 2 parents 10f812c + 712dbfe
@boblail boblail authored
Showing with 13 additions and 2 deletions.
  1. +12 −1 spec/cookie-spec.coffee
  2. +1 −1  src/zombie/cookies.coffee
View
13 spec/cookie-spec.coffee
@@ -14,9 +14,11 @@ brains.get "/cookies", (req, res)->
res.cookie "_domain2", "not here", "Domain": "not.localhost"
res.cookie "_domain3", "wrong", "Domain": "notlocalhost"
res.send "<html></html>"
+
brains.get "/cookies/echo", (req,res)->
cookies = ("#{k}=#{v}" for k,v of req.cookies).join("; ")
res.send "<html>#{cookies}</html>"
+
brains.get "/cookies_redirect", (req, res)->
res.cookie "_expires5", "3s", "Expires": new Date(Date.now() + 3000), "Path": "/"
res.redirect "/"
@@ -56,7 +58,7 @@ vows.describe("Cookies").addBatch(
map[name] = value
map
, {}
- "should include only visibile cookies": (pairs)->
+ "should include only visible cookies": (pairs)->
keys = (key for key, value of pairs).sort()
assert.deepEqual keys, "_domain1 _expires1 _expires2 _name _path1".split(" ")
"should match name to value": (pairs)->
@@ -105,4 +107,13 @@ vows.describe("Cookies").addBatch(
assert.isUndefined cookies._domain2
assert.isUndefined cookies._domain3
+ "setting cookies from subdomains":
+ topic: (browser)->
+ browser = new zombie.Browser()
+ browser.cookies("www.localhost").update("foo=bar; domain=.localhost")
+ @callback null, browser
+ "should be accessible": (browser)->
+ assert.equal "bar", browser.cookies("localhost").get("foo")
+ assert.equal "bar", browser.cookies("www.localhost").get("foo")
+
).export(module)
View
2  src/zombie/cookies.coffee
@@ -23,7 +23,7 @@ class Cookies
domainMatch = (domain, hostname)->
return true if domain == hostname
- return domain.charAt(0) == "." && domain.substring(1) == hostname.replace(/^[^.]\./, "")
+ return domain.charAt(0) == "." && domain.substring(1) == hostname.replace(/^[^.]+\./, "")
# Return all the cookies that match the given hostname/path, from most
# specific to least specific. Returns array of arrays, each item is
Please sign in to comment.
Something went wrong with that request. Please try again.