about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-04-24 02:08:59 +0900
committerEugen <eugen@zeonfederated.com>2017-04-23 19:08:59 +0200
commitd670f72830bfc81126c604723c65008afa81d77e (patch)
tree14c90ec1d77dd1fa9f979da842c758b0d6105dd5
parent57cd6546c3864f7cd5bac244d88f1923a53e2c1a (diff)
Show multibyte URI preview card (#2363)
-rw-r--r--app/services/fetch_link_card_service.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb
index f24ebb82b..31f9be194 100644
--- a/app/services/fetch_link_card_service.rb
+++ b/app/services/fetch_link_card_service.rb
@@ -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?