From fb3a59c0541fef61be622a18a79c822192c85420 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Fri, 15 Oct 2021 08:12:15 +0200 Subject: [PATCH] fix: Return 409 when there is a slash semantics issue --- src/storage/DataAccessorBasedStore.ts | 2 +- test/unit/storage/DataAccessorBasedStore.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/storage/DataAccessorBasedStore.ts b/src/storage/DataAccessorBasedStore.ts index decf053eb..fab78e372 100644 --- a/src/storage/DataAccessorBasedStore.ts +++ b/src/storage/DataAccessorBasedStore.ts @@ -193,7 +193,7 @@ export class DataAccessorBasedStore implements ResourceStore { // requests for the latter URI with a 301 redirect to the former." // https://solid.github.io/specification/protocol#uri-slash-semantics if (oldMetadata && oldMetadata.identifier.value !== identifier.path) { - throw new ForbiddenHttpError(`${identifier.path} conflicts with existing path ${oldMetadata.identifier.value}`); + throw new ConflictHttpError(`${identifier.path} conflicts with existing path ${oldMetadata.identifier.value}`); } const isContainer = this.isNewContainer(representation.metadata, identifier.path); diff --git a/test/unit/storage/DataAccessorBasedStore.test.ts b/test/unit/storage/DataAccessorBasedStore.test.ts index 7fe7c5adc..774cbc9b4 100644 --- a/test/unit/storage/DataAccessorBasedStore.test.ts +++ b/test/unit/storage/DataAccessorBasedStore.test.ts @@ -358,7 +358,7 @@ describe('A DataAccessorBasedStore', (): void => { representation.metadata.identifier = DataFactory.namedNode(`${resourceID.path}/`); const prom = store.setRepresentation(resourceID, representation); await expect(prom).rejects.toThrow(`${resourceID.path} conflicts with existing path ${resourceID.path}/`); - await expect(prom).rejects.toThrow(ForbiddenHttpError); + await expect(prom).rejects.toThrow(ConflictHttpError); }); it('throws a 412 if the conditions are not matched.', async(): Promise => {