Skip to content

Commit

Permalink
ldp.remote.store: add context if it is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
srosset81 committed Jun 24, 2024
1 parent 07e0725 commit 48d8cf4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/middleware/packages/jsonld/services/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ module.exports = {
},
toRDF(ctx) {
const { input, options } = ctx.params;
if (!input['@context']) throw new Error(`Cannot convert JSON-LD to RDF because no JSON-LD context is provided`);
return this.jsonld.toRDF(input, options);
},
// Return quads in RDF.JS data model
Expand Down
8 changes: 8 additions & 0 deletions src/middleware/packages/ldp/services/remote/actions/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ module.exports = {
throw new Error(`The resourceUri param must be remote. Provided: ${resourceUri} (webId ${webId})`);
}

// Adds the default context, if it is missing
if (!resource['@context']) {
resource = {
'@context': await ctx.call('jsonld.context.get'),
...resource
};
}

if (!dataset && this.settings.podProvider) {
if (!webId) {
throw new Error(`In Pod provider config, a webId or dataset param must be provided to ldp.remote.store`);
Expand Down

0 comments on commit 48d8cf4

Please sign in to comment.