fix: Prevent slugs with trailing slashes for non-container resources

* fix: slugs ending on slash with link header cannot create containers

* refactor(DataAccessorBasedStore): removing duplicate code and errors

* test(ServerFetch): fix integration tests that create a container

* fix: Reinstate original checks in setResource to let tests succeed

* test: change to container paths to end in / on POST only

* refactor: incorporate review changes

* fix: Error check was too strict

Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com>

* test: make testcase to test allowed slash behaviour

* test: removed unnecessary code from tests

* test: remove metadata line and duplicate tests

Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com>
This commit is contained in:
Thomas Dupont
2022-02-23 14:35:02 +01:00
committed by GitHub
parent bf1afdd6ec
commit 5965268ebf
4 changed files with 50 additions and 15 deletions

View File

@@ -265,14 +265,14 @@ describe.each(stores)('An LDP handler allowing all requests %s', (name, { storeC
});
it('can create a container with a diamond identifier in the data.', async(): Promise<void> => {
const slug = 'my-container';
const slug = 'my-container/';
const body = '<> <http://www.w3.org/2000/01/rdf-schema#label> "My Container" .';
let response = await postResource(baseUrl, { isContainer: true, contentType: 'text/turtle', slug, body });
expect(response.headers.get('location')).toBe(`${baseUrl}${slug}/`);
expect(response.headers.get('location')).toBe(`${baseUrl}${slug}`);
// GET
const containerUrl = `${baseUrl}${slug}/`;
const containerUrl = `${baseUrl}${slug}`;
response = await getResource(containerUrl);
await expectQuads(response, [