diff --git a/src/storage/conversion/ConstantConverter.ts b/src/storage/conversion/ConstantConverter.ts index a19cce4be..fa7a8d7af 100644 --- a/src/storage/conversion/ConstantConverter.ts +++ b/src/storage/conversion/ConstantConverter.ts @@ -110,10 +110,12 @@ export class ConstantConverter extends RepresentationConverter { } // Only replace the representation if it matches the media range settings - if (!this.options.enabledMediaRanges.some((type): boolean => matchesMediaType(sourceContentType, type))) { + if (!isContainer && + !this.options.enabledMediaRanges.some((type): boolean => matchesMediaType(sourceContentType, type))) { throw new NotImplementedHttpError(`${sourceContentType} is not one of the enabled media types.`); } - if (this.options.disabledMediaRanges.some((type): boolean => matchesMediaType(sourceContentType, type))) { + if (!isContainer && + this.options.disabledMediaRanges.some((type): boolean => matchesMediaType(sourceContentType, type))) { throw new NotImplementedHttpError(`${sourceContentType} is one of the disabled media types.`); } } diff --git a/test/unit/storage/conversion/ConstantConverter.test.ts b/test/unit/storage/conversion/ConstantConverter.test.ts index d6d27d66f..d6d322dfe 100644 --- a/test/unit/storage/conversion/ConstantConverter.test.ts +++ b/test/unit/storage/conversion/ConstantConverter.test.ts @@ -76,7 +76,7 @@ describe('A ConstantConverter', (): void => { it('does not support representations if their content-type is not enabled.', async(): Promise => { const preferences = { type: { 'text/html': 1 }}; const representation = { metadata: new RepresentationMetadata({ [CONTENT_TYPE]: 'text/plain' }) } as any; - const args = { identifier: { path: 'container/' }, representation, preferences }; + const args = { identifier, representation, preferences }; converter = new ConstantConverter('abc/def/index.html', 'text/html', { enabledMediaRanges: [ 'text/turtle' ]}); @@ -86,7 +86,7 @@ describe('A ConstantConverter', (): void => { it('does not support representations if their content-type is disabled.', async(): Promise => { const preferences = { type: { 'text/html': 1 }}; const representation = { metadata: new RepresentationMetadata({ [CONTENT_TYPE]: 'text/plain' }) } as any; - const args = { identifier: { path: 'container/' }, representation, preferences }; + const args = { identifier, representation, preferences }; converter = new ConstantConverter('abc/def/index.html', 'text/html', { disabledMediaRanges: [ 'text/*' ]});