Skip to content

Commit

Permalink
Fix to handle multiple # in vocab URIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Hale committed Nov 10, 2021
1 parent 3ea6c18 commit ab4bc73
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions model/VocabularyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/VocabularyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/testconfig.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@
skosmos:language "en";
skosmos:sparqlGraph <http://www.skosmos.skos/testOrder/> .

<http://testMultiHashesInUri#vocab#multiHashVocabId> a skosmos:Vocabulary, void:Dataset ;

<http://skosmos.skos/dump/test/groups> dc:format "application/rdf+xml" .

:cat_science a skos:Concept ;
Expand Down

0 comments on commit ab4bc73

Please sign in to comment.