mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Store content type parameters
* feat: support storage and retrievel of content-type parameters * test: extra unit tests for parseContentTypeWithParameters * refactor: simplify set contentType() Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com> * refactor: simplify for loop because of unique blankNodes Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com> * refactor: ContentTypeParameter should be contentTypeParameter Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com> * refactor: remove undefined type in favor of var? syntax Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com> * refactor: use new parseContentType internally * chore: remove commented code * docs: code documentation line changed Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com> * refactor: Check for faulty metadata in contentType rdf structure Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com> * refactor: remove all instances of blanknodes Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com> * refactor: use full contentType when parsing header Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com> * refactor: use quads() method instead of store.getQuads() * refactor: .value needed for type correctness * feat: ReprMetadata constructor now supports full content-type string Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com>
This commit is contained in:
@@ -190,16 +190,31 @@ describe('HeaderUtil', (): void => {
|
||||
|
||||
describe('#parseContentType', (): void => {
|
||||
const contentTypeTurtle = 'text/turtle';
|
||||
const contentTypePlain: any = {
|
||||
value: 'text/plain',
|
||||
parameters: {
|
||||
charset: 'utf-8',
|
||||
},
|
||||
};
|
||||
it('handles single content-type parameter (with leading and trailing whitespaces).', (): void => {
|
||||
expect(parseContentType('text/turtle').type).toEqual(contentTypeTurtle);
|
||||
expect(parseContentType('text/turtle ').type).toEqual(contentTypeTurtle);
|
||||
expect(parseContentType(' text/turtle').type).toEqual(contentTypeTurtle);
|
||||
expect(parseContentType('text/turtle').value).toEqual(contentTypeTurtle);
|
||||
expect(parseContentType('text/turtle ').value).toEqual(contentTypeTurtle);
|
||||
expect(parseContentType(' text/turtle').value).toEqual(contentTypeTurtle);
|
||||
expect(parseContentType('text/plain; charset=utf-8')).toEqual(contentTypePlain);
|
||||
expect(parseContentType(' text/plain; charset=utf-8')).toEqual(contentTypePlain);
|
||||
expect(parseContentType('text/plain ; charset=utf-8')).toEqual(contentTypePlain);
|
||||
expect(parseContentType(' text/plain ; charset=utf-8')).toEqual(contentTypePlain);
|
||||
expect(parseContentType(' text/plain ; charset="utf-8"')).toEqual(contentTypePlain);
|
||||
expect(parseContentType(' text/plain ; charset = "utf-8"')).toEqual(contentTypePlain);
|
||||
});
|
||||
|
||||
it('handles multiple content-type parameters.', (): void => {
|
||||
expect(parseContentType('text/turtle; charset=UTF-8').type).toEqual(contentTypeTurtle);
|
||||
expect(parseContentType('text/turtle; charset=UTF-8').value).toEqual(contentTypeTurtle);
|
||||
contentTypePlain.parameters.test = 'value1';
|
||||
expect(parseContentType('text/plain; charset=utf-8;test="value1"')).toEqual(contentTypePlain);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#parseForwarded', (): void => {
|
||||
it('handles an empty set of headers.', (): void => {
|
||||
expect(parseForwarded({})).toEqual({});
|
||||
|
||||
Reference in New Issue
Block a user