mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Add HTTP::Cookie#dot_domain.
This commit is contained in:
parent
f5bc5032dd
commit
f2ea366de2
2 changed files with 9 additions and 0 deletions
|
|
@ -386,6 +386,12 @@ class HTTP::Cookie
|
|||
@domain = @domain_name.hostname
|
||||
end
|
||||
|
||||
# Returns the domain, with a dot prefixed only if the domain flag is
|
||||
# on.
|
||||
def dot_domain
|
||||
@for_domain ? '.' << @domain : @domain
|
||||
end
|
||||
|
||||
# Returns the domain attribute value as a DomainName object.
|
||||
attr_reader :domain_name
|
||||
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
|
||||
assert_equal 'example.com', cookie.domain
|
||||
assert cookie.for_domain?
|
||||
assert_equal '.example.com', cookie.dot_domain
|
||||
end
|
||||
|
||||
def test_parse_domain_no_dot
|
||||
|
|
@ -173,6 +174,7 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
|
||||
assert_equal 'example.com', cookie.domain
|
||||
assert cookie.for_domain?
|
||||
assert_equal '.example.com', cookie.dot_domain
|
||||
end
|
||||
|
||||
def test_parse_domain_none
|
||||
|
|
@ -184,6 +186,7 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
|
||||
assert_equal 'example.com', cookie.domain
|
||||
assert !cookie.for_domain?
|
||||
assert_equal 'example.com', cookie.dot_domain
|
||||
end
|
||||
|
||||
def test_parse_max_age
|
||||
|
|
|
|||
Loading…
Reference in a new issue