Parse URL when checking for approved museums

This commit is contained in:
Alex Cabal 2024-01-10 14:02:15 -06:00
parent 60eb118524
commit 57ed9c5c1e
2 changed files with 10 additions and 3 deletions

View file

@ -462,11 +462,11 @@ class Artwork extends PropertiesBase{
$parsedUrl = parse_url($url); $parsedUrl = parse_url($url);
} }
catch(Exception){ catch(Exception){
throw new InvalidUrlException($url); throw new Exceptions\InvalidUrlException($url);
} }
if(!is_array($parsedUrl)){ if(!is_array($parsedUrl)){
throw new InvalidUrlException($url); throw new Exceptions\InvalidUrlException($url);
} }
if(stripos($parsedUrl['host'], 'hathitrust.org') !== false){ if(stripos($parsedUrl['host'], 'hathitrust.org') !== false){

View file

@ -9,12 +9,19 @@ class Museum extends PropertiesBase{
throw new Exceptions\MuseumNotFoundException(); throw new Exceptions\MuseumNotFoundException();
} }
try{
$parsedUrl = parse_url($url);
}
catch(Exception){
throw new Exceptions\InvalidUrlException($url);
}
$result = Db::Query(' $result = Db::Query('
SELECT * SELECT *
from Museums from Museums
where ? like concat("%", Domain, "%") where ? like concat("%", Domain, "%")
limit 1; limit 1;
', [$url], 'Museum'); ', [$parsedUrl['host']], 'Museum');
if(sizeof($result) == 0){ if(sizeof($result) == 0){
throw new Exceptions\MuseumNotFoundException(); throw new Exceptions\MuseumNotFoundException();