diff --git a/__tests__/fixtures/version-2/Osbornfa1.json b/__tests__/fixtures/version-2/Osbornfa1.json new file mode 100644 index 0000000000000000000000000000000000000000..cd506c9e123c18bcee2c016773f2b0a9d75f8f5d --- /dev/null +++ b/__tests__/fixtures/version-2/Osbornfa1.json @@ -0,0 +1,42 @@ +{ + "@id": "https://manifests.britishart.yale.edu/Osbornfa1", + "@type": "sc:Manifest", + "description": "Osborn fa1 IIIF Manifest created for the Digitally Enabled Scholarship with Medieval Manuscripts project at Yale University.", + "label": "New Haven, Beinecke Rare Book and Manuscript Library, Yale University, Osborn fa1", + "sequences": [ + { + "@id": "https://manifests.britishart.yale.edu/sequence/Osbornfa1", + "@type": "sc:Sequence", + "canvases": [ + { + "@id": "http://scale.ydc2.yale.edu/canvas/684c8053-0247-45a2-b55d-10dd3defebe4", + "@type": "sc:Canvas", + "height": 4438, + "images": [ + { + "@id": "http://scale.ydc2.yale.edu/annotation/b38081da-8991-4464-a71e-d9891226a35f", + "@type": "oa:Annotation", + "motivation": "sc:painting", + "on": "http://scale.ydc2.yale.edu/canvas/684c8053-0247-45a2-b55d-10dd3defebe4", + "resource": { + "@id": "https://images.britishart.yale.edu/iiif/b38081da-8991-4464-a71e-d9891226a35f/full/full/0/native.jpg", + "@type": "dctypes:Image", + "format": "image/jpeg", + "height": 4438, + "label": "Osborn fa1, [Bookplates]", + "service": { + "@id": "https://images.britishart.yale.edu/iiif/b38081da-8991-4464-a71e-d9891226a35f/", + "profile": "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1", + "@context": "http://iiif.io/api/image/1/context.json" + }, + "width": 3603 + } + } + ], + "label": "Osborn fa1, [Bookplates]", + "width": 3603 + } + ] + } + ] +} diff --git a/__tests__/src/lib/ManifestoCanvas.test.js b/__tests__/src/lib/ManifestoCanvas.test.js index db78149caf81ff53946a8832d016341866fc59bd..11f1876f4b8c3df1d37a8f6e8fd3f3526c3e5f66 100644 --- a/__tests__/src/lib/ManifestoCanvas.test.js +++ b/__tests__/src/lib/ManifestoCanvas.test.js @@ -1,6 +1,7 @@ import manifesto from 'manifesto.js'; import ManifestoCanvas from '../../../src/lib/ManifestoCanvas'; import fixture from '../../fixtures/version-2/019.json'; +import imagev1Fixture from '../../fixtures/version-2/Osbornfa1.json'; describe('ManifestoCanvas', () => { let instance; @@ -16,6 +17,17 @@ describe('ManifestoCanvas', () => { ); }); }); + describe('imageInformationUri', () => { + it('correctly returns an image information url for a v2 Image API', () => { + expect(instance.imageInformationUri).toEqual('https://stacks.stanford.edu/image/iiif/hg676jb4964%2F0380_796-44/info.json'); + }); + it('correctly returns an image information url for a v1 Image API', () => { + const imagev1Instance = new ManifestoCanvas( + manifesto.create(imagev1Fixture).getSequences()[0].getCanvases()[0], + ); + expect(imagev1Instance.imageInformationUri).toEqual('https://images.britishart.yale.edu/iiif/b38081da-8991-4464-a71e-d9891226a35f/info.json'); + }); + }); describe('aspectRatio', () => { it('calculates a width / height aspectRatio', () => { expect(instance.aspectRatio).toBeCloseTo(0.667); diff --git a/src/lib/ManifestoCanvas.js b/src/lib/ManifestoCanvas.js index 96aac9c16b197b9d74cea5345d0712a600aae8ba..2a4a7fb69f2189da9a150349cbf779c47ff3ab8e 100644 --- a/src/lib/ManifestoCanvas.js +++ b/src/lib/ManifestoCanvas.js @@ -25,7 +25,9 @@ export default class ManifestoCanvas { /** */ get imageInformationUri() { - return `${this.canvas.getImages()[0].getResource().getServices()[0].id}/info.json`; + return `${ + this.canvas.getImages()[0].getResource().getServices()[0].id.replace(/\/$/, '') + }/info.json`; } /**