Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #7270

Closed
Open
Created Jul 07, 2014 by Administrator@rootOwner

Avatar and relative URL

Created by: darinkes

Hi,

Just updated from 6.9 to 7.0, worked great by the way. Only one minor issue came up so far. User avatars are not shown anymore. Group avatars are still shown correctly.

Some digging brought up avatar_url in app/models/user.rb, which combines Gitlab.config.gitlab.url and avatar.url via URI::join. This call seems to drop my relative_url = "/gitlab"

I added this to the model: logger.info Gitlab.config.gitlab.url logger.info avatar.url logger.info URI::join(Gitlab.config.gitlab.url, avatar.url).to_s

This is in log: http:/test.foo.de/gitlab /uploads/user/avatar/2/Scruffy.png http://test.foo.de/uploads/user/avatar/2/Scruffy.png

Some checking with irb:

$ irb
irb(main):001:0> require 'uri'
=> true
irb(main):002:0> mainurl = "http://tst.bla.foo/gitlab"
=> "http://tst.bla.foo/gitlab"
irb(main):003:0>  picurl = "/uploads/user/avatar/bla.png"
=> "/uploads/user/avatar/bla.png"
irb(main):004:0> URI::join(mainurl, picurl)
=> #<URI::HTTP:0x007f02ad0748b8 URL:http://tst.bla.foo/uploads/user/avatar/bla.png>

==> URI:join really drops the relative-url appendix :(

I fixed it for now by dropping URI:Join and returning avatar.url instead, like in group_icon() in application_helper.rb does.

Any reason to use URI::join here?

diff --git a/app/models/user.rb b/app/models/user.rb
index 2352f8c..694bfda 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -485,7 +485,8 @@ class User < ActiveRecord::Base

   def avatar_url(size = nil)
     if avatar.present?
-      URI::join(Gitlab.config.gitlab.url, avatar.url).to_s
+      #URI::join(Gitlab.config.gitlab.url, avatar.url).to_s
+      avatar.url
     else
       GravatarService.new.execute(email, size)
     end
Assignee
Assign to
Time tracking