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
+20 -15
View File
@@ -242,22 +242,27 @@ 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') {
case 'http://library.stanford.edu/iiif/image-api/1.1/context.json': context = [context];
case 'http://iiif.io/api/image/1/context.json': }
return Versions.VERSION1; for (let i = 0; i < context.length; i++) {
case 'http://iiif.io/api/image/2/context.json': switch (context[i]) {
return Versions.VERSION2; case 'http://library.stanford.edu/iiif/image-api/1.1/context.json':
case 'http://iiif.io/api/image/3/context.json': case 'http://iiif.io/api/image/1/context.json':
return Versions.VERSION3;
case undefined:
// Image API 1.0 has no '@context'
if (this.getComplianceLevelEntryFromProfile(Versions.VERSION1) && this.imageInfo.identifier) {
return Versions.VERSION1; return Versions.VERSION1;
} case 'http://iiif.io/api/image/2/context.json':
break; return Versions.VERSION2;
default: case 'http://iiif.io/api/image/3/context.json':
return Versions.VERSION3;
case 'ol-no-context':
// Image API 1.0 has no '@context'
if (this.getComplianceLevelEntryFromProfile(Versions.VERSION1) && this.imageInfo.identifier) {
return Versions.VERSION1;
}
break;
default:
}
} }
assert(false, 61); assert(false, 61);
} }