Skip to content

Commit

Permalink
fix: pod url construction when not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximvdw committed Dec 5, 2024
1 parent 85ecc34 commit 84ebd07
Show file tree
Hide file tree
Showing 2 changed files with 281 additions and 273 deletions.
22 changes: 17 additions & 5 deletions src/common/SolidService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,14 @@ export abstract class SolidService extends RemoteService {
fetch: session.fetch,
})
.then((value) => {
// No storage
if (value[0] === undefined) {
return reject(
new Error(
'No pod URL found! Please ensure you have a pim:storage or solid:storage predicate in your profile document!',
),
);
// Get the POD url based on the web id by removing /profile/card#me
const webIdURL = new URL(session.info.webId);
webIdURL.hash = '';
webIdURL.pathname = webIdURL.pathname.replace(/\/profile\/card$/, '/');
resolve(webIdURL.href as IriString);
return;
}
resolve(value[0] as IriString);
})
Expand Down Expand Up @@ -558,6 +560,16 @@ export abstract class SolidService extends RemoteService {
});
}

/**
* Set a thing in a session Pod
* @param {SolidSession} session Solid session to set a thing to
* @param {ThingPersisted} thing Persisted thing to store in the Pod
* @returns {Promise<SolidDataset>} Promise if stored
*/
setThing(session: SolidSession, thing: ThingPersisted): Promise<SolidDataset> {
return this.createThing(session, thing);
}

/**
* Set a thing in a session Pod
* @param {SolidSession} session Solid session to set a thing to
Expand Down
Loading

0 comments on commit 84ebd07

Please sign in to comment.