Skip to content

Commit

Permalink
refactor: simplify set contentType()
Browse files Browse the repository at this point in the history
Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com>
  • Loading branch information
Falx and joachimvh committed Mar 7, 2022
1 parent ef6a52c commit 242bd8a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/http/representation/RepresentationMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,17 @@ export class RepresentationMetadata {
}

private setContentTypeParams(input: ContentType | string | undefined): void {
if (input === undefined) {
this.removeContentTypeParameters();
// Make sure complete Content-Type RDF structure is gone
this.removeContentTypeParameters();

if (!input) {
return;
}

if (typeof input === 'string') {
input = parseContentTypeWithParameters(input);
}

// Make sure complete Content-Type RDF structure is gone
this.removeContentTypeParameters();

Object.entries(input.parameters ?? []).forEach(([ paramKey, paramValue ], idx): void => {
const paramNode = DataFactory.blankNode(`parameter${idx + 1}`);
this.addQuad(this.id, SOLID_META.terms.ContentTypeParameter, paramNode);
Expand Down

0 comments on commit 242bd8a

Please sign in to comment.