sources: add image_url?, page_url?, and profile_url? methods.
Add methods to Source::URL for determining whether a URL is an image URL, a page URL, or a profile URL. Also add more source URL tests and fix various URL parsing bugs.
This commit is contained in:
@@ -11,14 +11,14 @@ class Source::Extractor
|
||||
end
|
||||
|
||||
def image_urls
|
||||
return [parsed_url.full_image_url] if parsed_url.image_url?
|
||||
return [parsed_url.full_image_url] if parsed_url.full_image_url.present?
|
||||
return [image_from_downloadable(parsed_url)] if parsed_url.downloadable?
|
||||
|
||||
images = images_for_post.presence || images_for_product.presence || []
|
||||
|
||||
full_images = images.compact.map do |image|
|
||||
parsed = Source::URL.parse(image)
|
||||
if parsed&.image_url?
|
||||
if parsed&.full_image_url.present?
|
||||
parsed.full_image_url
|
||||
elsif parsed&.downloadable?
|
||||
image_from_downloadable(parsed)
|
||||
|
||||
@@ -12,7 +12,7 @@ class Source::Extractor
|
||||
end
|
||||
|
||||
def image_urls
|
||||
return [find_largest(parsed_url)].compact if parsed_url.asset_url?
|
||||
return [find_largest(parsed_url)].compact if parsed_url.image_url?
|
||||
|
||||
assets = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user