mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-04-27 14:57:46 +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
|
@domain = @domain_name.hostname
|
||||||
end
|
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.
|
# Returns the domain attribute value as a DomainName object.
|
||||||
attr_reader :domain_name
|
attr_reader :domain_name
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ class TestHTTPCookie < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_equal 'example.com', cookie.domain
|
assert_equal 'example.com', cookie.domain
|
||||||
assert cookie.for_domain?
|
assert cookie.for_domain?
|
||||||
|
assert_equal '.example.com', cookie.dot_domain
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parse_domain_no_dot
|
def test_parse_domain_no_dot
|
||||||
|
|
@ -173,6 +174,7 @@ class TestHTTPCookie < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_equal 'example.com', cookie.domain
|
assert_equal 'example.com', cookie.domain
|
||||||
assert cookie.for_domain?
|
assert cookie.for_domain?
|
||||||
|
assert_equal '.example.com', cookie.dot_domain
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parse_domain_none
|
def test_parse_domain_none
|
||||||
|
|
@ -184,6 +186,7 @@ class TestHTTPCookie < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_equal 'example.com', cookie.domain
|
assert_equal 'example.com', cookie.domain
|
||||||
assert !cookie.for_domain?
|
assert !cookie.for_domain?
|
||||||
|
assert_equal 'example.com', cookie.dot_domain
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parse_max_age
|
def test_parse_max_age
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue