Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Should be able to access all cookies from path "/"
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed Nov 30, 2012
1 parent 2d658e8 commit 00dee2c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/zombie/cookies.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Access
# Returns all the cookies for this domain/path.
all: ->
return @_cookies.all().filter((cookie)=>
return Tough.domainMatch(@domain, cookie.domain) && Tough.pathMatch(@path, cookie.path) && cookie.TTL() > 0
pathMatches = @path == "/" || Tough.pathMatch(@path, cookie.path)
return Tough.domainMatch(@domain, cookie.domain) && pathMatches && cookie.TTL() > 0
).sort(Tough.cookieCompare)

# Returns the value of a cookie.
Expand Down Expand Up @@ -45,8 +46,10 @@ class Access
# Delete cookie before setting it, so we only store one cookie (per
# domain/path/name)
@_cookies.filter((c)=> !(cookie.key == c.key && cookie.domain == c.domain && cookie.path == c.path) )
if Tough.domainMatch(cookie.domain, @domain) && Tough.pathMatch(cookie.path, @path) && cookie.TTL() > 0
@_cookies.push cookie
pathMatches = @path == "/" || Tough.pathMatch(@path, cookie.path)
if Tough.domainMatch(cookie.domain, @domain) && pathMatches && cookie.TTL() > 0
@_cookies.push(cookie)
return

# Deletes a cookie.
#
Expand Down Expand Up @@ -75,8 +78,9 @@ class Access
# Delete cookie before setting it, so we only store one cookie (per
# domain/path/name)
@_cookies.filter((c)-> !(cookie.key == c.key && cookie.domain == c.domain && cookie.path == c.path) )
if Tough.domainMatch(@domain, cookie.domain) && Tough.pathMatch(@path, cookie.path) && cookie.TTL() > 0
@_cookies.push cookie
pathMatches = @path == "/" || Tough.pathMatch(@path, cookie.path)
if Tough.domainMatch(@domain, cookie.domain) && pathMatches && cookie.TTL() > 0
@_cookies.push(cookie)

# Adds Cookie header suitable for sending to the server.
addHeader: (headers)->
Expand Down

0 comments on commit 00dee2c

Please sign in to comment.