summaryrefslogtreecommitdiff
path: root/lib/uri
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-21 16:03:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-21 16:03:59 +0000
commitb6e2c52857056b41de8391816fe373de47f32c84 (patch)
treed72904310edb3ec5f5667cfa15c757c005757189 /lib/uri
parent7506fde3e911100ccca169eff3a5f4916e8ed1da (diff)
Docs and tests on URI.hierarchical?, URI.absolute?
Improve code coverage and clarify meaning of hierarchical based on RFC text. [Fix GH-1846] From: Xavier Riley <xavriley@hotmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri')
-rw-r--r--lib/uri/generic.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index 140fb055de..16cc8885bb 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -946,7 +946,25 @@ module URI
end
#
- # Checks if URI has a path
+ # Returns true if URI is hierarchical
+ #
+ # == Description
+ #
+ # URI has components listed in order of decreashing signficance from left to right
+ # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3
+ #
+ # == Usage
+ #
+ # require 'uri'
+ #
+ # uri = URI.parse("http://my.example.com/")
+ # => #<URI::HTTP http://my.example.com/>
+ # uri.hierarchical?
+ # # => true
+ # uri = URI.parse("mailto:joe@example.com")
+ # => #<URI::MailTo mailto:joe@example.com>
+ # uri.hierarchical?
+ # # => false
#
def hierarchical?
if @path
@@ -957,7 +975,7 @@ module URI
end
#
- # Checks if URI is an absolute one
+ # Returns true if URI has a scheme (e.g. http:// or https://) specified
#
def absolute?
if @scheme
@@ -969,7 +987,7 @@ module URI
alias absolute absolute?
#
- # Checks if URI is relative
+ # Returns true if URI does not have a scheme (e.g. http:// or https://) specified
#
def relative?
!absolute?