Skip to content

Commit

Permalink
WIP fix landing page presenter when image not present
Browse files Browse the repository at this point in the history
  • Loading branch information
richardTowers committed Nov 6, 2024
1 parent 53498f2 commit 4d47f8d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/presenters/publishing_api/landing_page_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def recursively_expand_images(input)
in String => s if s =~ IMAGE_PATTERN
image_id = IMAGE_PATTERN.match(s).captures.first
image = item.images.find { _1.filename == image_id }
present_image(image)
present_image(image, s)
in Hash => h
h.transform_values { recursively_expand_images(_1) }
in Array => a
Expand All @@ -76,8 +76,8 @@ def recursively_expand_images(input)
end
end

def present_image(image)
return { errors: ["Image not found for pattern #{s}"] } if image.nil?
def present_image(image, pattern)
return { errors: ["Image not found for pattern #{pattern}"] } if image.nil?

result = {
id: image.filename,
Expand Down

0 comments on commit 4d47f8d

Please sign in to comment.