Yet another relative_url_root + avatar_url issue
Created by: julian7
I upgraded gitlab to 7.0, just to find out avatar uploads are broken, as they don't honor relative_url_path
. AFAIK the regression was introduced by ae564c97.
If I'm not mistaken the old behavior was controlled at client side, but now it's constructed at server side.
However, URI::join
doesn't work the same way as +
operator with javascript strings:
irb(main):052:0> URI::join("http://example.com", "uploads").to_s
=> "http://example.com/uploads"
irb(main):053:0> URI::join("http://example.com/gitlab", "uploads").to_s
=> "http://example.com/uploads"
irb(main):054:0> URI::join("http://example.com/gitlab/", "uploads").to_s
=> "http://example.com/gitlab/uploads"
irb(main):055:0> URI::join("http://example.com", "/uploads").to_s
=> "http://example.com/uploads"
irb(main):056:0> URI::join("http://example.com/gitlab", "/uploads").to_s
=> "http://example.com/uploads"
irb(main):057:0> URI::join("http://example.com/gitlab/", "/uploads").to_s
=> "http://example.com/uploads"
According to this, the only way to get the correct URL if you either end your base URL with a slash, and you don't start additional parts with slash. Alternatively, we can also prepend AttachmentUploader
's default_url
with relative_url_root
.