twitter: include artist name in source URLs on post pages.

Show Twitter sources on post pages like this:

    https://twitter.com/BOW999/status/1261877313349640194

and not like this:

    https://twitter.com/i/web/status/1261877313349640194

We originally removed the artist name because the link would be broken
when the artist changed their name. This is no longer the case.
This commit is contained in:
evazion
2021-09-27 11:07:25 -05:00
parent 4477984d2d
commit 738be825ff
2 changed files with 6 additions and 5 deletions

View File

@@ -151,8 +151,9 @@ module Sources::Strategies
end
def normalize_for_source
status_id = self.class.status_id_from_url(url)
if status_id.present?
if tag_name_from_url.present? && status_id.present?
"https://twitter.com/#{tag_name_from_url}/status/#{status_id}"
elsif status_id.present?
"https://twitter.com/i/web/status/#{status_id}"
elsif url =~ %r{\Ahttps?://(?:o|image-proxy-origin)\.twimg\.com/\d/proxy\.jpg\?t=(\w+)&}i
str = Base64.decode64($1)

View File

@@ -316,9 +316,9 @@ module Sources
source4 = "https://twitter.com/BOW999/status/1261877313349640194?s=19"
assert_equal(source1, Sources::Strategies.normalize_source(source1))
assert_equal(source1, Sources::Strategies.normalize_source(source2))
assert_equal(source1, Sources::Strategies.normalize_source(source3))
assert_equal(source1, Sources::Strategies.normalize_source(source4))
assert_equal(source2, Sources::Strategies.normalize_source(source2))
assert_equal(source2, Sources::Strategies.normalize_source(source3))
assert_equal(source2, Sources::Strategies.normalize_source(source4))
end
should "normalize twimg twitpic correctly" do