mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Merge pull request #10 from marxarelli/fix/host-only-cookie-domain-comparison
Fix host-only cookies for unqualified hostnames
This commit is contained in:
commit
24b5d407d9
2 changed files with 11 additions and 2 deletions
|
|
@ -67,10 +67,8 @@ class HTTP::CookieJar
|
|||
def each(uri = nil) # :yield: cookie
|
||||
now = Time.now
|
||||
if uri
|
||||
thost = DomainName.new(uri.host)
|
||||
tpath = uri.path
|
||||
@jar.each { |domain, paths|
|
||||
next unless thost.cookie_domain?(domain)
|
||||
paths.each { |path, hash|
|
||||
next unless HTTP::Cookie.path_match?(path, tpath)
|
||||
hash.delete_if { |name, cookie|
|
||||
|
|
|
|||
|
|
@ -139,6 +139,17 @@ module TestHTTPCookieJar
|
|||
assert_equal(0, @jar.cookies(URI('http://www.rubyforge.org/')).length)
|
||||
end
|
||||
|
||||
def test_host_only_with_unqualified_hostname
|
||||
@jar.add(HTTP::Cookie.new(cookie_values(
|
||||
:origin => 'http://localhost/', :domain => 'localhost', :for_domain => false)))
|
||||
|
||||
assert_equal(1, @jar.cookies(URI('http://localhost/')).length)
|
||||
|
||||
assert_equal(1, @jar.cookies(URI('http://Localhost/')).length)
|
||||
|
||||
assert_equal(1, @jar.cookies(URI('https://Localhost/')).length)
|
||||
end
|
||||
|
||||
def test_empty_value
|
||||
url = URI 'http://rubyforge.org/'
|
||||
values = cookie_values(:value => "")
|
||||
|
|
|
|||
Loading…
Reference in a new issue