Skip to content
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
6 changes: 4 additions & 2 deletions src/storage/conversion/ConstantConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/storage/conversion/ConstantConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('A ConstantConverter', (): void => {
it('does not support representations if their content-type is not enabled.', async(): Promise<void> => {
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' ]});

Expand All @@ -86,7 +86,7 @@ describe('A ConstantConverter', (): void => {
it('does not support representations if their content-type is disabled.', async(): Promise<void> => {
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/*' ]});

Expand Down
Loading