mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Parse content-type more strictly
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { HttpResponse } from '../../../src/server/HttpResponse';
|
||||
import { BadRequestHttpError } from '../../../src/util/errors/BadRequestHttpError';
|
||||
import {
|
||||
addHeader,
|
||||
parseAccept,
|
||||
@@ -213,6 +214,10 @@ describe('HeaderUtil', (): void => {
|
||||
contentTypePlain.parameters.test = 'value1';
|
||||
expect(parseContentType('text/plain; charset=utf-8;test="value1"')).toEqual(contentTypePlain);
|
||||
});
|
||||
|
||||
it('errors on invalid content-types.', (): void => {
|
||||
expect((): any => parseContentType('invalid type')).toThrow(BadRequestHttpError);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#parseForwarded', (): void => {
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('ResourceUtil', (): void => {
|
||||
let representation: Representation;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
representation = new BasicRepresentation('data', 'metadata');
|
||||
representation = new BasicRepresentation('data', 'meta/data');
|
||||
});
|
||||
|
||||
describe('#updateModifiedDate', (): void => {
|
||||
@@ -55,7 +55,7 @@ describe('ResourceUtil', (): void => {
|
||||
|
||||
it('ensures that original representation does not update when the clone is updated.', async(): Promise<void> => {
|
||||
const res = await cloneRepresentation(representation);
|
||||
res.metadata.contentType = 'typetype';
|
||||
res.metadata.contentType = 'type/type';
|
||||
expect(representation.metadata.contentType).not.toBe(res.metadata.contentType);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user