diff --git a/app/Matchers/AuthorityMatcher.php b/app/Matchers/AuthorityMatcher.php index 4da2ec1e6..452582899 100644 --- a/app/Matchers/AuthorityMatcher.php +++ b/app/Matchers/AuthorityMatcher.php @@ -97,7 +97,7 @@ protected function findByFullname($fullname) public static function parse($author) { - if (!preg_match('/^((?.*?)\s*(?\(.*\))?(?\s+-\s+.*)?,\s+)?(?.*?)\s*(?\(.*\))?$/', $author, $matches)) { + if (!preg_match('/^((?.*?)\s*(?\(.*\))?(?\s+-\s+.*)?,\s+)?(?.*?)\s*(?\(.*\)|\/.*)?$/', $author, $matches)) { return null; } @@ -106,7 +106,7 @@ public static function parse($author) 'alt_surname' => trim($matches['alt_surname'], '()'), 'role' => ltrim($matches['role'], ' -'), 'name' => $matches['name'], - 'alt_name' => trim($matches['alt_name'] ?? '', '()'), + 'alt_name' => trim($matches['alt_name'] ?? '', '()/'), ]; } } \ No newline at end of file diff --git a/tests/Matchers/AuthorityMatcherTest.php b/tests/Matchers/AuthorityMatcherTest.php index f8a05e866..3af7844f1 100644 --- a/tests/Matchers/AuthorityMatcherTest.php +++ b/tests/Matchers/AuthorityMatcherTest.php @@ -142,7 +142,7 @@ public function testParseName() $this->assertEquals('Rembrandt van Rijn', $parsed['name']); } - public function testParseNameWithAltName() + public function testParseNameWithAltNameInBrackets() { $author = 'Toyen (Marie Čermínová)'; $parsed = AuthorityMatcher::parse($author); @@ -151,6 +151,15 @@ public function testParseNameWithAltName() $this->assertEquals('Marie Čermínová', $parsed['alt_name']); } + public function testParseNameWithAltNameAfterSlash() + { + $author = 'Toyen /Marie Čermínová'; + $parsed = AuthorityMatcher::parse($author); + + $this->assertEquals('Toyen', $parsed['name']); + $this->assertEquals('Marie Čermínová', $parsed['alt_name']); + } + public function testParseSurnameAndName() { $author = 'Wouwerman, Philips';