Allow https links to the library of congress subject headings

This commit is contained in:
Joshua Ramon Enslin 2023-07-27 01:43:54 +02:00
parent 0e86361968
commit f5673c69fd
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 7 additions and 4 deletions

View File

@ -353,7 +353,10 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
private static function validateLcshId(string $id):string|false {
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
$id = strtr($id, ['http://id.loc.gov/authorities/names/' => '']);
$id = strtr($id, [
'http://id.loc.gov/authorities/names/' => '',
'https://id.loc.gov/authorities/names/' => '',
]);
}
if (substr($id, 0, 2) !== 'sh') {

View File

@ -40,9 +40,9 @@ final class MDNodaRepositoryTest extends TestCase {
self::assertNotFalse(MDNodaRepository::loc->validateId("n2022014604"));
self::assertNotFalse(MDNodaRepository::loc->validateId("https://id.loc.gov/authorities/names/n2022014604"));
self::assertNotFalse(MDNodaRepository::loc->validateId("http://id.loc.gov/authorities/names/n2022014604"));
self::assertNotFalse(MDNodaRepository::loc->validateId("n2022014604"));
self::assertNotFalse(MDNodaRepository::lcsh->validateId("https://id.loc.gov/authorities/names/sh2022014604"));
self::assertNotFalse(MDNodaRepository::lcsh->validateId("http://id.loc.gov/authorities/names/sh2022014604"));
self::assertNotFalse(MDNodaRepository::lcsh->validateId("sh2022014604"));
}
}