From ab4bc734a320d9771efeda9317f2d2148ba5abfa Mon Sep 17 00:00:00 2001 From: Mark Hale Date: Wed, 10 Nov 2021 08:41:26 +0000 Subject: [PATCH] Fix to handle multiple # in vocab URIs. --- model/VocabularyConfig.php | 4 ++-- tests/VocabularyTest.php | 9 +++++++++ tests/testconfig.ttl | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/model/VocabularyConfig.php b/model/VocabularyConfig.php index 117533758..93dca9f5e 100644 --- a/model/VocabularyConfig.php +++ b/model/VocabularyConfig.php @@ -536,10 +536,10 @@ public function getDefaultSidebarView() public function getId() { $uriparts = explode("#", $this->resource->getURI()); - if (count($uriparts) != 1) + if (count($uriparts) > 1) // hash namespace { - return $uriparts[1]; + return $uriparts[count($uriparts) - 1]; } // slash namespace diff --git a/tests/VocabularyTest.php b/tests/VocabularyTest.php index 425d45aa8..19a680aa9 100644 --- a/tests/VocabularyTest.php +++ b/tests/VocabularyTest.php @@ -25,6 +25,15 @@ public function testGetId() { $this->assertEquals('test', $id); } + /** + * @covers Vocabulary::getId + */ + public function testGetMultiHashId() { + $vocab = $this->model->getVocabulary('multiHashVocabId'); + $id = $vocab->getId(); + $this->assertEquals('multiHashVocabId', $id); + } + /** * @covers Vocabulary::getTitle */ diff --git a/tests/testconfig.ttl b/tests/testconfig.ttl index ddc8b8ad6..66657e16f 100644 --- a/tests/testconfig.ttl +++ b/tests/testconfig.ttl @@ -429,6 +429,8 @@ skosmos:language "en"; skosmos:sparqlGraph . + a skosmos:Vocabulary, void:Dataset ; + dc:format "application/rdf+xml" . :cat_science a skos:Concept ;