Prepare IIIFInfo for JSON-LD context extensions

IIIF Image API 3 allows context extensions that should be added to the
info.json's @context property. Therefore, '@context' might be an array
instead of a string.
This commit is contained in:
Lutz Helm
2019-04-16 08:48:17 +02:00
committed by Lutz Helm
parent f68b8d8df9
commit d332b6a0f4
+8 -3
View File
@@ -242,8 +242,12 @@ class IIIFInfo {
if (this.imageInfo === undefined) { if (this.imageInfo === undefined) {
return; return;
} }
const context = this.imageInfo['@context'] || undefined; let context = this.imageInfo['@context'] || 'ol-no-context';
switch (context) { if (typeof context == 'string') {
context = [context];
}
for (let i = 0; i < context.length; i++) {
switch (context[i]) {
case 'http://library.stanford.edu/iiif/image-api/1.1/context.json': case 'http://library.stanford.edu/iiif/image-api/1.1/context.json':
case 'http://iiif.io/api/image/1/context.json': case 'http://iiif.io/api/image/1/context.json':
return Versions.VERSION1; return Versions.VERSION1;
@@ -251,7 +255,7 @@ class IIIFInfo {
return Versions.VERSION2; return Versions.VERSION2;
case 'http://iiif.io/api/image/3/context.json': case 'http://iiif.io/api/image/3/context.json':
return Versions.VERSION3; return Versions.VERSION3;
case undefined: case 'ol-no-context':
// Image API 1.0 has no '@context' // Image API 1.0 has no '@context'
if (this.getComplianceLevelEntryFromProfile(Versions.VERSION1) && this.imageInfo.identifier) { if (this.getComplianceLevelEntryFromProfile(Versions.VERSION1) && this.imageInfo.identifier) {
return Versions.VERSION1; return Versions.VERSION1;
@@ -259,6 +263,7 @@ class IIIFInfo {
break; break;
default: default:
} }
}
assert(false, 61); assert(false, 61);
} }