Skip to content

Commit

Permalink
Fix local context URL when a basePath is used
Browse files Browse the repository at this point in the history
  • Loading branch information
srosset81 committed Jun 25, 2024
1 parent a2bfd85 commit f09a715
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/middleware/packages/jsonld/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,27 @@ module.exports = {
throw new Error('The baseUri and localContextPath settings are required');
}

let localContextUri;
if (localContextPath.startsWith('.well-known') || localContextPath.startsWith('/.well-known')) {
// For /.well-known URIs, use the root path
const { origin } = new URL(baseUri);
localContextUri = urlJoin(origin, localContextPath);
} else {
localContextUri = urlJoin(baseUri, localContextPath);
}

this.broker.createService({
mixins: [JsonLdDocumentLoaderService],
settings: {
cachedContextFiles,
localContextUri: urlJoin(baseUri, localContextPath)
localContextUri
}
});

this.broker.createService({
mixins: [JsonLdContextService],
settings: {
localContextUri: urlJoin(baseUri, localContextPath)
localContextUri
}
});

Expand Down

0 comments on commit f09a715

Please sign in to comment.