diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 49082424c..0a6d6bfc9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -107,12 +107,10 @@ module ApplicationHelper time_tag(time.strftime("%Y-%m-%d %H:%M"), time) end - def external_link_to(url, options = {}) - if options[:truncate] - text = truncate(url, length: options[:truncate]) - else - text = url - end + def external_link_to(url, truncate: nil, strip_scheme: false) + text = url + text = text.gsub(%r!\Ahttps?://!i, "") if strip_scheme + text = text.truncate(truncate) if truncate if url =~ %r!\Ahttps?://!i link_to text, url, {rel: :nofollow} diff --git a/app/views/related_tags/_source_tags.html.erb b/app/views/related_tags/_source_tags.html.erb index 13b2a0cea..3808645ff 100644 --- a/app/views/related_tags/_source_tags.html.erb +++ b/app/views/related_tags/_source_tags.html.erb @@ -19,10 +19,10 @@ <% artist.sorted_urls.each do |url| %>
  • <% if url.is_active %> - <%= external_link_to url.url, truncate: 30 %> + <%= external_link_to url.url, truncate: 64, strip_scheme: true %> <%= link_to tag.i(class: "fas fa-minus-circle"), artist_url_path(id: url.id, artist_url: { is_active: false }), remote: true, method: :put, "data-confirm": "This will mark the URL as inactive. Continue?" %> <% else %> - <%= truncate(url.url, length: 30) %> + <%= external_link_to url.url, truncate: 64, strip_scheme: true %> <% end %>
  • <% end %>