Permalink
Browse files

if cookies don't specify a path '/' should be used by default

  • Loading branch information...
1 parent 54eae31 commit 122681b96fa68ded53cef246f55cf8d243b22d7a @boblail boblail committed Jan 20, 2011
Showing with 5 additions and 3 deletions.
  1. +4 −2 spec/cookie-spec.coffee
  2. +1 −1 src/zombie/cookies.coffee
View
@@ -84,9 +84,10 @@ vows.describe("Cookies").addBatch(
browser.cookies("localhost").set "_expires2", "0s", "max-age": 0
browser.cookies("localhost", "/cookies").set "_path1", "here"
browser.cookies("localhost", "/cookies/echo").set "_path2", "here"
- browser.cookies("localhost", "/jars").set "_path3", "there"
- browser.cookies("localhost", "/cookies/fido").set "_path4", "there"
+ browser.cookies("localhost", "/jars").set "_path3", "there", "path": "/jars"
+ browser.cookies("localhost", "/cookies/fido").set "_path4", "there", "path": "/cookies/fido"
browser.cookies("localhost", "/jars").set "_path5", "here", "path": "/cookies"
+ browser.cookies("localhost", "/jars").set "_path6", "here"
browser.cookies(".localhost").set "_domain1", "here"
browser.cookies("not.localhost").set "_domain2", "there"
browser.cookies("notlocalhost").set "_domain3", "there"
@@ -104,6 +105,7 @@ vows.describe("Cookies").addBatch(
assert.equal cookies._path1, "here"
assert.equal cookies._path2, "here"
"should pass cookies that specified a different path when they were assigned": (cookies)-> assert.equal cookies._path5, "here"
+ "should pass cookies that didn't specify a path when they were assigned": (cookies)-> assert.equal cookies._path6, "here"
"should not pass unrelated path cookies to server": (cookies)->
assert.isUndefined cookies._path3
assert.isUndefined cookies._path4
@@ -79,7 +79,7 @@ class Cookies
@remove(name, options)
else
in_domain = cookies[options.domain || hostname] ||= {}
- in_path = in_domain[options.path || pathname] ||= {}
+ in_path = in_domain[options.path || '/'] ||= {}
in_path[name] = state
#### cookies(host, path).remove(name, options?)

2 comments on commit 122681b

Contributor

vinibaggio replied Jan 20, 2011

Fantastic! Thanks!

Contributor

boblail replied Jan 20, 2011

No problem!

Please sign in to comment.