mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Allow quad data for containers
This prevents the container data check from throwing an error when converting to quads if the incoming data already is quads.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import arrayifyStream from 'arrayify-stream';
|
||||
import { DataFactory } from 'n3';
|
||||
import type { Quad } from 'rdf-js';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
@@ -240,7 +241,12 @@ export class DataAccessorBasedStore implements ResourceStore {
|
||||
protected async handleContainerData(representation: Representation): Promise<void> {
|
||||
let quads: Quad[];
|
||||
try {
|
||||
quads = await parseQuads(representation.data);
|
||||
// No need to parse the data if it already contains internal/quads
|
||||
if (representation.metadata.contentType === INTERNAL_QUADS) {
|
||||
quads = await arrayifyStream(representation.data);
|
||||
} else {
|
||||
quads = await parseQuads(representation.data);
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
throw new BadRequestHttpError(`Can only create containers with RDF data. ${error.message}`);
|
||||
|
||||
Reference in New Issue
Block a user