Browse Source

Return false if object does not respond to url (#5988)

Avoid error when the service returns a mostly valid oembed, but has no
url in it, causing a MethodError: undefined method `url'
for #<OEmbed::Response::Photo:0x000056505def9620>
pull/4/head
Renato "Lond" Cerqueira 6 years ago
committed by Eugen Rochko
parent
commit
19257d91bf
1 changed files with 1 additions and 0 deletions
  1. +1
    -0
      app/services/fetch_link_card_service.rb

+ 1
- 0
app/services/fetch_link_card_service.rb View File

@ -87,6 +87,7 @@ class FetchLinkCardService < BaseService
when 'link'
@card.image = URI.parse(response.thumbnail_url) if response.respond_to?(:thumbnail_url)
when 'photo'
return false unless response.respond_to?(:url)
@card.embed_url = response.url
@card.width = response.width.presence || 0
@card.height = response.height.presence || 0

Loading…
Cancel
Save