]> cat aescling's git repositories - mastodon.git/commitdiff
Don't capture scheme-less URLs in the status (#5435)
authorunarist <m.unarist@gmail.com>
Tue, 17 Oct 2017 16:32:25 +0000 (01:32 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 17 Oct 2017 16:32:25 +0000 (18:32 +0200)
Specifically, this fixes status length calculation to be same as JS side.

BTW, since this pattern used in not only preview card fetching, we
should extract it (with twitter-regex?) and write tests I think.

app/services/fetch_link_card_service.rb

index 7029c4d757bf6243ede863b3d1dbd4af5e9f96ae..14c21b6ccf8274eda18316796296bfaef864daf2 100644 (file)
@@ -3,7 +3,7 @@
 class FetchLinkCardService < BaseService
   URL_PATTERN = %r{
     (                                                                                                 #   $1 URL
-      (https?:\/\/)?                                                                                  #   $2 Protocol (optional)
+      (https?:\/\/)                                                                                   #   $2 Protocol (required)
       (#{Twitter::Regex[:valid_domain]})                                                              #   $3 Domain(s)
       (?::(#{Twitter::Regex[:valid_port_number]}))?                                                   #   $4 Port number (optional)
       (/#{Twitter::Regex[:valid_url_path]}*)?                                                         #   $5 URL Path and anchor