diff --git a/app/helpers/url_helper.rb b/app/helpers/url_helper.rb new file mode 100644 index 00000000000..131a7204973 --- /dev/null +++ b/app/helpers/url_helper.rb @@ -0,0 +1,7 @@ +module UrlHelper + def append_https(url) + return "" if url.blank? + return url if url.start_with?("https://") + return "https://#{url}" + end +end \ No newline at end of file diff --git a/app/views/dashboards/_subject.html.erb b/app/views/dashboards/_subject.html.erb index f774e819177..1f32e6a6dcd 100644 --- a/app/views/dashboards/_subject.html.erb +++ b/app/views/dashboards/_subject.html.erb @@ -26,10 +26,10 @@ <%= icon_tag("link", color: :primary, class: "w-6 text-orange mr-3") %>

<%= link_to( - truncate(user.homepage_url, length: 20), - h(user.homepage_url), + truncate(append_https(user.homepage_url), length: 20), + h(append_https(user.homepage_url)), rel: "nofollow", - data: { confirm: "You are about to be redirected #{user.homepage_url}" } + data: { confirm: "You are about to be redirected #{h(append_https(user.homepage_url))}" } ) %>

diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb index a51f1a62309..e4a16b9f70f 100644 --- a/app/views/profiles/show.html.erb +++ b/app/views/profiles/show.html.erb @@ -98,11 +98,11 @@

<%= link_to( - truncate(@user.homepage_url,length: 20), - h(@user.homepage_url), + truncate(h(append_https(@user.homepage_url)),length: 20), + h(append_https(@user.homepage_url)), rel: "nofollow", class: "profile__header__attribute t-link--black", - data: { confirm: "You are about to be redirected #{@user.homepage_url}" } + data: { confirm: "You are about to be redirected #{{h(append_https(user.homepage_url))}}" } ) %>