Browse Source

Show multibyte URI preview card (#2363)

closed-social-glitch-2
Yamagishi Kazutoshi 7 years ago
committed by Eugen
parent
commit
d670f72830
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      app/services/fetch_link_card_service.rb

+ 2
- 1
app/services/fetch_link_card_service.rb View File

@ -1,11 +1,12 @@
# frozen_string_literal: true
class FetchLinkCardService < BaseService
URL_PATTERN = %r{https?://\S+}
USER_AGENT = "#{HTTP::Request::USER_AGENT} (Mastodon/#{Mastodon::VERSION}; +http://#{Rails.configuration.x.local_domain}/)"
def call(status)
# Get first http/https URL that isn't local
url = URI.extract(status.text).reject { |uri| (uri =~ /\Ahttps?:\/\//).nil? || TagManager.instance.local_url?(uri) }.first
url = status.text.match(URL_PATTERN).to_a.reject { |uri| TagManager.instance.local_url?(uri) }.first
return if url.nil?

Loading…
Cancel
Save