mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 14:17:59 +01:00
don't try to parse a nil uri
This commit is contained in:
parent
7fd9d7e45a
commit
756d2c91a6
1 changed files with 5 additions and 6 deletions
|
@ -54,12 +54,8 @@ defmodule PhilomenaWeb.DuplicateReportView do
|
|||
def same_source?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
||||
do: to_string(duplicate_of_image.source_url) == to_string(image.source_url)
|
||||
|
||||
def similar_source?(%{image: image, duplicate_of_image: duplicate_of_image}) do
|
||||
host1 = URI.parse(image.source_url).host
|
||||
host2 = URI.parse(duplicate_of_image.source_url).host
|
||||
|
||||
host1 == host2
|
||||
end
|
||||
def similar_source?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
||||
do: uri_host(image.source_url) == uri_host(duplicate_of_image.source_url)
|
||||
|
||||
def source_on_target?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
||||
do: present?(duplicate_of_image.source_url) and blank?(image.source_url)
|
||||
|
@ -125,4 +121,7 @@ defmodule PhilomenaWeb.DuplicateReportView do
|
|||
|
||||
defp proper_subset?(set1, set2),
|
||||
do: MapSet.subset?(set1, set2) and not MapSet.equal?(set1, set2)
|
||||
|
||||
defp uri_host(nil), do: nil
|
||||
defp uri_host(str), do: URI.parse(str).host
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue