Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only shorten URIs of types in the SKOS namespace in the search results #1284

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion model/sparql/GenericSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
12 changes: 6 additions & 6 deletions tests/RestControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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":[
{
Expand All @@ -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":[
{
Expand All @@ -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":[
{
Expand Down