sources: fix sources sometimes choosing wrong strategy (fix #3968)

Fix sources choosing the wrong strategy when the referer belongs to a
different site (for example, when uploading a twitter post with a pixiv
referer).

* Fix `match?` to only consider the main url, not the referer.

* Change `match?` to match against a list of domains given by the `domains` method.

* Change `match?` to an instance method.
This commit is contained in:
evazion
2018-11-04 13:00:17 -06:00
parent 4219163042
commit 5cf6a43918
13 changed files with 58 additions and 37 deletions

View File

@@ -9,10 +9,6 @@ module Sources::Strategies
# https://developer.twitter.com/en/docs/developer-utilities/configuration/api-reference/get-help-configuration
RESERVED_USERNAMES = %w[home i intent search]
def self.match?(*urls)
urls.compact.any? { |x| x =~ PAGE || x =~ ASSET}
end
def self.enabled?
TwitterService.new.enabled?
end
@@ -35,6 +31,10 @@ module Sources::Strategies
end
end
def domains
["twitter.com", "twimg.com"]
end
def site_name
"Twitter"
end