diff --git a/model/sparql/GenericSparql.php b/model/sparql/GenericSparql.php index ccf40b30b..caf6678e0 100644 --- a/model/sparql/GenericSparql.php +++ b/model/sparql/GenericSparql.php @@ -166,7 +166,8 @@ private function shortenUri($uri) { if (!array_key_exists($uri, $this->qnamecache)) { $res = new EasyRdf\Resource($uri); $qname = $res->shorten(); // returns null on failure - $this->qnamecache[$uri] = ($qname !== null) ? $qname : $uri; + // only URIs in the SKOS namespace are shortened + $this->qnamecache[$uri] = ($qname !== null && strpos($qname, "skos:") === 0) ? $qname : $uri; } return $this->qnamecache[$uri]; } diff --git a/tests/RestControllerTest.php b/tests/RestControllerTest.php index 531692da3..fd8380bc3 100644 --- a/tests/RestControllerTest.php +++ b/tests/RestControllerTest.php @@ -190,7 +190,7 @@ public function testSearchJsonLd() { "uri":"http://www.skosmos.skos/test/ta117", "type":[ "skos:Concept", - "meta:TestClass" + "http://www.skosmos.skos/test-meta/TestClass" ], "prefLabel":"3D Bass", "lang":"en", @@ -200,7 +200,7 @@ public function testSearchJsonLd() { "uri":"http://www.skosmos.skos/test/ta116", "type":[ "skos:Concept", - "meta:TestClass" + "http://www.skosmos.skos/test-meta/TestClass" ], "prefLabel":"Bass", "lang":"en", @@ -210,7 +210,7 @@ public function testSearchJsonLd() { "uri":"http://www.skosmos.skos/test/ta122", "type":[ "skos:Concept", - "meta:TestClass" + "http://www.skosmos.skos/test-meta/TestClass" ], "prefLabel":"Black sea bass", "lang":"en", @@ -259,7 +259,7 @@ public function testSearchJsonLdWithAdditionalFields() { "uri":"http://www.skosmos.skos/test/ta117", "type":[ "skos:Concept", - "meta:TestClass" + "http://www.skosmos.skos/test-meta/TestClass" ], "broader":[ { @@ -279,7 +279,7 @@ public function testSearchJsonLdWithAdditionalFields() { "uri":"http://www.skosmos.skos/test/ta116", "type":[ "skos:Concept", - "meta:TestClass" + "http://www.skosmos.skos/test-meta/TestClass" ], "broader":[ { @@ -294,7 +294,7 @@ public function testSearchJsonLdWithAdditionalFields() { "uri":"http://www.skosmos.skos/test/ta122", "type":[ "skos:Concept", - "meta:TestClass" + "http://www.skosmos.skos/test-meta/TestClass" ], "broader":[ {