summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorBen Bodenmiller <bbodenmiller@hotmail.com>2015-08-05 00:48:16 -0700
committerBen Bodenmiller <bbodenmiller@hotmail.com>2015-08-05 00:48:16 -0700
commit0f785bbc7ecf932e81c84ec98636ffd305994b47 (patch)
treeb6b2e70cf0c1897ca30bfea68891ff266059d77c /config
parent88a3cfe1070bbd7db450f68b8fc2b509c795e413 (diff)
downloadgitlab-ce-0f785bbc7ecf932e81c84ec98636ffd305994b47.tar.gz
ink to configured gravatar host on profile page
Diffstat (limited to 'config')
-rw-r--r--config/initializers/1_settings.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index bd76c918485..026c1a5792c 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -8,6 +8,15 @@ class Settings < Settingslogic
def gitlab_on_standard_port?
gitlab.port.to_i == (gitlab.https ? 443 : 80)
end
+
+ # get host without www, thanks to http://stackoverflow.com/a/6674363/1233435
+ def get_host_without_www(url)
+ url = URI.encode(url)
+ uri = URI.parse(url)
+ uri = URI.parse("http://#{url}") if uri.scheme.nil?
+ host = uri.host.downcase
+ host.start_with?('www.') ? host[4..-1] : host
+ end
private
@@ -147,6 +156,7 @@ Settings['gravatar'] ||= Settingslogic.new({})
Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil?
Settings.gravatar['plain_url'] ||= 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
+Settings.gravatar['host'] = Settings.get_host_without_www(Settings.gravatar['plain_url'])
#
# GitLab Shell