@ -399,6 +399,38 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a PIM ID, returning a string or false.
|
||||
*
|
||||
* @param string $id ID to validate.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private static function validatePimId(string $id):string|false {
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$toRemove = [];
|
||||
foreach ([
|
||||
'https://opac-nevter.pim.hu/en/record/-/record/',
|
||||
'https://resolver.pim.hu/auth/',
|
||||
] as $prefix) {
|
||||
$toRemove[$prefix] = "";
|
||||
}
|
||||
$id = strtr($id, $toRemove);
|
||||
}
|
||||
|
||||
// There is an issue with this regex
|
||||
if (preg_match("/^[0-9-PIM]*$/", $id) === false) {
|
||||
return false;
|
||||
}
|
||||
if (is_numeric(substr($id, 3)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a wikidata ID, returning a string or false.
|
||||
*
|
||||
@ -484,7 +516,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
self::oberbegriffsdatei => self::validateNumericId($id, ['https://term.museum-digital.de/oberbegriffsdatei/tag/']),
|
||||
self::orcid => preg_match('/^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}$/', $id) ? $id : false,
|
||||
self::osm => self::validateNumericId($id, ['https://www.openstreetmap.org/relation/']),
|
||||
self::pim => self::validateNumericId($id, ['https://opac-nevter.pim.hu/en/record/-/record/']),
|
||||
self::pim => self::validatePimId($id),
|
||||
self::pleiades => self::validateNumericId($id, ['https://pleiades.stoa.org/places/']),
|
||||
self::rkd => self::validateNumericId($id, ['http://rkd.nl/explore/artists/', 'https://rkd.nl/explore/artists/']),
|
||||
self::ulan => self::validateNumericId($id, ['http://vocab.getty.edu/ulan/', 'http://vocab.getty.edu/page/ulan/', 'https://vocab.getty.edu/page/ulan/']),
|
||||
|
Reference in New Issue
Block a user