fix: Prefer Turtle as default content type.

Fixes https://github.com/solid/community-server/issues/463
This commit is contained in:
Ruben Verborgh
2021-01-05 22:27:03 +01:00
parent ba5c62059a
commit e70e060225
3 changed files with 54 additions and 5 deletions

View File

@@ -17,12 +17,21 @@ import { TypedRepresentationConverter } from './TypedRepresentationConverter';
* Converts `internal/quads` to most major RDF serializations.
*/
export class QuadToRdfConverter extends TypedRepresentationConverter {
private readonly outputPreferences?: ValuePreferences;
public constructor(options: { outputPreferences?: Record<string, number> } = {}) {
super();
if (Object.keys(options.outputPreferences ?? {}).length > 0) {
this.outputPreferences = { ...options.outputPreferences };
}
}
public async getInputTypes(): Promise<ValuePreferences> {
return { [INTERNAL_QUADS]: 1 };
}
public async getOutputTypes(): Promise<ValuePreferences> {
return rdfSerializer.getContentTypesPrioritized();
return this.outputPreferences ?? rdfSerializer.getContentTypesPrioritized();
}
public async handle(input: RepresentationConverterArgs): Promise<Representation> {