ruby / uri

URI is a module providing classes to handle Uniform Resource Identifiers
https://ruby.github.io/uri/
Other
78 stars 42 forks source link

Regression in URI.join #83

Open casperisfine opened 1 year ago

casperisfine commented 1 year ago

The logic of this code is questionable, but it has worked for a while and the behavior seem to have changed in the last couple weeks:

puts URI.join("http://example.com/", "//", "path")

3.2 and older:

http://example.com/path

3.3.0-dev:

http:///path

I'll try to figure out what caused this and provide a fix.

casperisfine commented 1 year ago

Bisecting show that https://github.com/ruby/uri/commit/c1d1757d2f2dfccc69db93308887bbb48247e85c is what introduced the failure.

FYI @nobu

casperisfine commented 1 year ago

I see you worked on it in 6b64023.

To be honest, reviewing our code, File.join is a much better method for what the author wanted to do.

I don't think the new behavior of URI.join is necessarily wrong, if you consider its implementation. It's just that the name is a bit confusing. join suggest nothing is lost, URI.join behaves more like a Hash#merge than File.join or Array#join.

I''m convinced that 99% of the time, users actually want File.join.