mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
This commit is contained in:
parent
c3ef5d5414
commit
a231f915a0
@ -13,6 +13,10 @@ class FetchLinkCardService < BaseService
|
||||
|
||||
url = Addressable::URI.parse(url).normalize.to_s
|
||||
card = PreviewCard.where(status: status).first_or_initialize(status: status, url: url)
|
||||
res = http_client.head(url)
|
||||
|
||||
return if res.code != 200 || res.mime_type != 'text/html'
|
||||
|
||||
attempt_opengraph(card, url) unless attempt_oembed(card, url)
|
||||
end
|
||||
|
||||
|
@ -2,6 +2,7 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe FetchLinkCardService do
|
||||
before do
|
||||
stub_request(:head, 'http://example.xn--fiqs8s/').to_return(status: 200, headers: { 'Content-Type' => 'text/html' })
|
||||
stub_request(:get, 'http://example.xn--fiqs8s/').to_return(request_fixture('idn.txt'))
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user