From a13851f29fb34a2d20e4eb2cd9372fd2be4ca341 Mon Sep 17 00:00:00 2001 From: Jackson Morgan Date: Fri, 10 May 2024 19:17:40 -0400 Subject: [PATCH] Resources remove the hash automatically --- packages/solid/src/resource/Leaf.ts | 7 ++++++- packages/solid/test/Integration.test.ts | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/solid/src/resource/Leaf.ts b/packages/solid/src/resource/Leaf.ts index d735c55..1490a0b 100644 --- a/packages/solid/src/resource/Leaf.ts +++ b/packages/solid/src/resource/Leaf.ts @@ -78,7 +78,9 @@ export class Leaf extends Resource { */ constructor(uri: LeafUri, context: SolidLdoDatasetContext) { super(context); - this.uri = uri; + const uriObject = new URL(uri); + uriObject.hash = ""; + this.uri = uriObject.toString() as LeafUri; this.requester = new LeafBatchedRequester(uri, context); this.status = { isError: false, type: "unfetched", uri }; } @@ -342,6 +344,9 @@ export class Leaf extends Resource { async getRootContainer(): Promise< Container | CheckRootResultError | NoRootContainerError > { + // Check to see if this document has a pim:storage if so, use that + + // If not, traverse the tree const parent = await this.getParentContainer(); return parent.getRootContainer(); } diff --git a/packages/solid/test/Integration.test.ts b/packages/solid/test/Integration.test.ts index deba138..c86e7dc 100644 --- a/packages/solid/test/Integration.test.ts +++ b/packages/solid/test/Integration.test.ts @@ -217,6 +217,18 @@ describe("Integration", () => { }); }); + /** + * General + */ + describe("General", () => { + it("Does not include the hash when creating a resource", () => { + const resource = solidLdoDataset.getResource( + "https://example.com/thing#hash", + ); + expect(resource.uri).toBe("https://example.com/thing"); + }); + }); + /** * Read */