mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-04-27 14:57:46 +00:00
CookiestxtSaver: Prefix the domain field with a dot if the domain flag is on.
The leading dot itself should be meaningless since there is the second field to tell if the cookie is issued for a domain and that was the reason I once removed it, but on second thought it doesn't hurt to put one.
This commit is contained in:
parent
f2ea366de2
commit
8b78e3d1e4
2 changed files with 9 additions and 3 deletions
|
|
@ -32,7 +32,7 @@ class HTTP::CookieJar::CookiestxtSaver < HTTP::CookieJar::AbstractSaver
|
||||||
def cookie_to_record(cookie)
|
def cookie_to_record(cookie)
|
||||||
cookie.instance_eval {
|
cookie.instance_eval {
|
||||||
[
|
[
|
||||||
@domain,
|
dot_domain,
|
||||||
@for_domain ? True : False,
|
@for_domain ? True : False,
|
||||||
@path,
|
@path,
|
||||||
@secure ? True : False,
|
@secure ? True : False,
|
||||||
|
|
|
||||||
|
|
@ -368,10 +368,16 @@ class TestHTTPCookieJar < Test::Unit::TestCase
|
||||||
assert_equal(3, @jar.cookies(url).length)
|
assert_equal(3, @jar.cookies(url).length)
|
||||||
|
|
||||||
Dir.mktmpdir do |dir|
|
Dir.mktmpdir do |dir|
|
||||||
@jar.save(File.join(dir, "cookies.txt"), :cookiestxt)
|
filename = File.join(dir, "cookies.txt")
|
||||||
|
@jar.save(filename, :cookiestxt)
|
||||||
|
|
||||||
|
content = File.read(filename)
|
||||||
|
|
||||||
|
assert_match(/^\.rubyforge\.org\t.*\tFoo\t/, content)
|
||||||
|
assert_match(/^rubyforge\.org\t.*\tBaz\t/, content)
|
||||||
|
|
||||||
jar = HTTP::CookieJar.new
|
jar = HTTP::CookieJar.new
|
||||||
jar.load(File.join(dir, "cookies.txt"), :cookiestxt) # HACK test the format
|
jar.load(filename, :cookiestxt) # HACK test the format
|
||||||
cookies = jar.cookies(url)
|
cookies = jar.cookies(url)
|
||||||
assert_equal(2, cookies.length)
|
assert_equal(2, cookies.length)
|
||||||
cookies.each { |cookie|
|
cookies.each { |cookie|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue