diff options
Diffstat (limited to 'lib/uri/generic.rb')
-rw-r--r-- | lib/uri/generic.rb | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index cfa0de6b74..bdd366661e 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -564,16 +564,26 @@ module URI end end - # Returns the user component. + # Returns the user component (without URI decoding). def user @user end - # Returns the password component. + # Returns the password component (without URI decoding). def password @password end + # Returns the user component after URI decoding. + def decoded_user + URI.decode_uri_component(@user) if @user + end + + # Returns the password component after URI decoding. + def decoded_password + URI.decode_uri_component(@password) if @password + end + # # Checks the host +v+ component for RFC2396 compliance # and against the URI::Parser Regexp for :HOST. @@ -935,7 +945,7 @@ module URI # == Description # # URI has components listed in order of decreasing significance from left to right, - # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3. + # see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3. # # == Usage # @@ -1354,6 +1364,9 @@ module URI str << ':' str << @port.to_s end + if (@host || @port) && !@path.empty? && !@path.start_with?('/') + str << '/' + end str << @path if @query str << '?' @@ -1366,6 +1379,7 @@ module URI end str end + alias to_str to_s # # Compares two URIs. @@ -1388,19 +1402,6 @@ module URI self.component_ary.eql?(oth.component_ary) end -=begin - ---- URI::Generic#===(oth) - -=end -# def ===(oth) -# raise NotImplementedError -# end - -=begin -=end - - # Returns an Array of the components defined from the COMPONENT Array. def component_ary component.collect do |x| |