diff options
author | Tiago <[email protected]> | 2021-09-20 22:53:42 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2021-10-22 19:48:36 +0900 |
commit | 553f234a07fe000cf5416793c1f9c0273518d906 (patch) | |
tree | bb1ead3c74236425986e27c5c6c1c9e8f0ce025c /test | |
parent | c8ad024e8e89550009bc4ee76fd6a4b22e18e207 (diff) |
[ruby/uri] URI#HTTP#origin and URI#HTTP#authority (https://github.com/ruby/uri/pull/30)
https://github.com/ruby/uri/commit/bf13946c32
Co-authored-by: Samuel Williams <[email protected]>
Diffstat (limited to 'test')
-rw-r--r-- | test/uri/test_http.rb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/test/uri/test_http.rb b/test/uri/test_http.rb index cc19046c8f..a52b4cfe28 100644 --- a/test/uri/test_http.rb +++ b/test/uri/test_http.rb @@ -24,14 +24,16 @@ class TestHTTP < Test::Unit::TestCase def test_parse u = URI.parse('http://a') assert_kind_of(URI::HTTP, u) - assert_equal(['http', - nil, 'a', URI::HTTP.default_port, - '', nil, nil], uri_to_ary(u)) + assert_equal([ + 'http', + nil, 'a', URI::HTTP.default_port, + '', nil, nil + ], uri_to_ary(u)) end def test_normalize host = 'aBcD' - u1 = URI.parse('http://' + host + '/eFg?HiJ') + u1 = URI.parse('http://' + host + '/eFg?HiJ') u2 = URI.parse('http://' + host.downcase + '/eFg?HiJ') assert(u1.normalize.host == 'abcd') assert(u1.normalize.path == u1.path) @@ -49,11 +51,11 @@ class TestHTTP < Test::Unit::TestCase end def test_request_uri - assert_equal('/', URI.parse('http://a.b.c/').request_uri) + assert_equal('/', URI.parse('http://a.b.c/').request_uri) assert_equal('/?abc=def', URI.parse('http://a.b.c/?abc=def').request_uri) - assert_equal('/', URI.parse('http://a.b.c').request_uri) + assert_equal('/', URI.parse('http://a.b.c').request_uri) assert_equal('/?abc=def', URI.parse('http://a.b.c?abc=def').request_uri) - assert_equal(nil, URI.parse('http:foo').request_uri) + assert_equal(nil, URI.parse('http:foo').request_uri) end def test_select @@ -64,6 +66,20 @@ class TestHTTP < Test::Unit::TestCase u.select(:scheme, :host, :not_exist, :port) end end + + def test_authority + assert_equal('a.b.c', URI.parse('http://a.b.c/').authority) + assert_equal('a.b.c:8081', URI.parse('http://a.b.c:8081/').authority) + assert_equal('a.b.c', URI.parse('http://a.b.c:80/').authority) + end + + + def test_origin + assert_equal('http://a.b.c', URI.parse('http://a.b.c/').origin) + assert_equal('http://a.b.c:8081', URI.parse('http://a.b.c:8081/').origin) + assert_equal('http://a.b.c', URI.parse('http://a.b.c:80/').origin) + assert_equal('https://a.b.c', URI.parse('https://a.b.c/').origin) + end end |