summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-05-16 14:23:09 +0000
committerDouwe Maan <douwe@gitlab.com>2017-05-16 14:23:09 +0000
commit0a8f3ba4d2fae41d232246b40f27e9d188e6f981 (patch)
tree71857cb43d45bdc4315783120af42398d7d96232
parent3d44ec3f4aa7180f2226f09064abe281c6b9d7be (diff)
parent835d4487fb7a67ff0f0254ee4120bcdf12be5a07 (diff)
downloadgitlab-ce-0a8f3ba4d2fae41d232246b40f27e9d188e6f981.tar.gz
Merge branch '31386-profile-fix-externallinks' into 'master'
Resolve "Make Twitter Link on Profile page useable by fixing wrong target URL's" Closes #31386 See merge request !10931
-rw-r--r--app/helpers/application_helper.rb18
-rw-r--r--app/views/users/show.html.haml4
2 files changed, 20 insertions, 2 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 97cf4863ddc..e5e64650708 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -278,4 +278,22 @@ module ApplicationHelper
def show_user_callout?
cookies[:user_callout_dismissed] == 'true'
end
+
+ def linkedin_url(user)
+ name = user.linkedin
+ if name =~ %r{\Ahttps?:\/\/(www\.)?linkedin\.com\/in\/}
+ name
+ else
+ "https://www.linkedin.com/in/#{name}"
+ end
+ end
+
+ def twitter_url(user)
+ name = user.twitter
+ if name =~ %r{\Ahttps?:\/\/(www\.)?twitter\.com\/}
+ name
+ else
+ "https://www.twitter.com/#{name}"
+ end
+ end
end
diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml
index 03e5dd97405..8e8b84e0408 100644
--- a/app/views/users/show.html.haml
+++ b/app/views/users/show.html.haml
@@ -56,11 +56,11 @@
= icon('skype')
- unless @user.linkedin.blank?
.profile-link-holder.middle-dot-divider
- = link_to "https://www.linkedin.com/in/#{@user.linkedin}", title: "LinkedIn" do
+ = link_to linkedin_url(@user), title: "LinkedIn" do
= icon('linkedin-square')
- unless @user.twitter.blank?
.profile-link-holder.middle-dot-divider
- = link_to "https://twitter.com/#{@user.twitter}", title: "Twitter" do
+ = link_to twitter_url(@user), title: "Twitter" do
= icon('twitter-square')
- unless @user.website_url.blank?
.profile-link-holder.middle-dot-divider