From: Scott Gonyea Date: 2012-02-22T11:45:44+09:00 Subject: [ruby-core:42795] [ruby-trunk - Bug #6057] URI - Nonsensical Behavior Issue #6057 has been updated by Scott Gonyea. Ah. That's the issue. 1.9.3-p125 :016 > uri = URI("http://google.com/foo/bar/") => # 1.9.3-p125 :017 > uri + "baz" => # If the URI's path itself has a trailing "/" then it will append the new path. Likewise: 1.9.3-p125 :023 > URI.join("http://google.com/foo/", "bar", "baz") => # 1.9.3-p125 :024 > URI.join("http://google.com/foo/", "bar/", "baz") => # 1.9.3-p125 :025 > How very unintuitive :(. I guess the next question would be if `URI.join` actually needs to follow the merge rules to the letter, but I imagine that argument is moot :). ---------------------------------------- Bug #6057: URI - Nonsensical Behavior https://bugs.ruby-lang.org/issues/6057 Author: Scott Gonyea Status: Open Priority: Normal Assignee: Category: lib Target version: ruby -v: 1.9.3-p125 The behavior of Ruby's URI is confusing, to say the least. URI("http://foo.com/bar") + "baz" # => # URI.join("http://foo.com/baz", "bar") # => # I could at least understand this behavior being the case if we were adding "/bar" (although it'd still be non-intuitive). That URI throws away its current path makes it a tedious library. Net::HTTP expects it as an input, yet as you interact with URI, you are constantly massaging it into and out of string form. In my opinion, URI should model the behavior of Pathname. -- http://bugs.ruby-lang.org/