diff options
Diffstat (limited to 'lib/uri')
-rw-r--r-- | lib/uri/generic.rb | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 6d42936bd0..a5ebaa11c3 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1329,7 +1329,7 @@ module URI # Destructive version of #normalize # def normalize! - if path && path == '' + if path && path.empty? set_path('/') end if scheme && scheme != scheme.downcase @@ -1342,11 +1342,7 @@ module URI # returns the assemble String with path and query components def path_query - str = @path - if @query - str += '?' + @query - end - str + @query ? "#@path?#@query" : @path end private :path_query @@ -1357,36 +1353,36 @@ module URI str = '' if @scheme str << @scheme - str << ':' + str << ':'.freeze end if @opaque str << @opaque - else if @host - str << '//' + str << '//'.freeze end if self.userinfo str << self.userinfo - str << '@' + str << '@'.freeze end if @host str << @host end if @port && @port != self.default_port - str << ':' + str << ':'.freeze str << @port.to_s end - - str << path_query + str << @path + if @query + str << '?'.freeze + str << @query + end end - if @fragment - str << '#' + str << '#'.freeze str << @fragment end - str end |