Skip to content

Commit

Permalink
reverting URL validation with and issue linked
Browse files Browse the repository at this point in the history
  • Loading branch information
soltanireza65 committed Nov 28, 2023
1 parent 28025b6 commit f87cdaa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
14 changes: 7 additions & 7 deletions bookmarks/vanilla/src/modules/Bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class Bookmark {
thing = setUrl(thing, RDF.type, BOOKMARK.Bookmark)

const updatedBookmarkList = setThing(ds, thing);

await saveSolidDatasetAt(indexUrl, updatedBookmarkList, { fetch: session.fetch });

return thing ? this.mapBookmark(thing) : undefined
Expand Down Expand Up @@ -222,12 +222,12 @@ export class Bookmark {
);
}
private static mapLink(thing: ThingPersisted): string {
const link = getLiteral(thing, BOOKMARK.recalls)?.value ?? getNamedNode(thing, BOOKMARK.recalls)?.value
if (link) {
return link
} else {
throw new Error("Bookmark link not found")
}
// TODO: validate url
// issue: https://github.com/solid-contrib/data-modules/issues/32
return (
getLiteral(thing, BOOKMARK.recalls)?.value ??
getNamedNode(thing, BOOKMARK.recalls)?.value ?? ""
);
}
private static mapCreated(thing: ThingPersisted): string | undefined {
return getLiteral(thing, DCTERMS.created)?.value
Expand Down
15 changes: 10 additions & 5 deletions bookmarks/vanilla/test/unit/Bookmark.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,12 @@ describe("Bookmark", () => {

const expected = {
url: 'https://fake-pod.net/path/to/bookmark-formats.ttl#one',
title: "updated",
link: "http://updated.com",
creator: "https://michielbdejong.solidcommunity.net/profile/card#me",
}
title: 'updated',
link: 'http://updated.com',
created: '2023-10-21T14:16:16Z',
updated: '2023-11-28T14:30:23.202Z',
creator: 'https://michielbdejong.solidcommunity.net/profile/card#me'
}

const responseGet: any = {
status: 200,
Expand All @@ -251,10 +253,13 @@ describe("Bookmark", () => {
const mock3 = jest.spyOn(inruptClient, "setThing").mockReturnValue(JSON.parse(loadFixture("ds-with-updated.json")));

const res = await Bookmark.update(url, payload, session);
console.log("🚀 ~ file: Bookmark.test.ts:254 ~ it ~ res:", res)

expect(Bookmark.getIndexUrl).toHaveBeenCalled();

expect(res).toEqual(expected);
expect(res?.title).toEqual(expected.title);
expect(res?.link).toEqual(expected.link);
expect(res?.creator).toEqual(expected.creator);

mock1.mockRestore();
mock2.mockRestore();
Expand Down

0 comments on commit f87cdaa

Please sign in to comment.