Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -1174,12 +1174,12 @@ async function _retrieveContextUrls(input, options) {
const {documentLoader} = options;

// retrieve all @context URLs in input
await retrieve(input, new Set(), documentLoader);
await retrieve(input, new Set(), documentLoader, options.base);

return input;

// recursive function that will retrieve all @context URLs in documents
async function retrieve(doc, cycles, documentLoader) {
async function retrieve(doc, cycles, documentLoader, baseUrl) {
if(cycles.size > MAX_CONTEXT_URLS) {
throw new JsonLdError(
'Maximum number of @context URLs exceeded.',
Expand All @@ -1189,7 +1189,7 @@ async function _retrieveContextUrls(input, options) {

// find all URLs in the given document
const urls = new Map();
_findContextUrls(doc, urls, false, options.base);
_findContextUrls(doc, urls, false, baseUrl);
if(urls.size === 0) {
return;
}
Expand Down Expand Up @@ -1256,13 +1256,13 @@ async function _retrieveContextUrls(input, options) {
}

// recurse
await retrieve(ctx, _cycles, documentLoader);
await retrieve(ctx, _cycles, documentLoader, url);

// store retrieved context w/replaced @context URLs
urls.set(url, ctx['@context']);

// replace all @context URLs in the document
_findContextUrls(doc, urls, true, options.base);
_findContextUrls(doc, urls, true, baseUrl);
}));
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/documentLoaders/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = ({
const statusText = http.STATUS_CODES[res.statusCode];
if(res.statusCode >= 400) {
throw new JsonLdError(
'URL could not be dereferenced: ' + statusText,
'URL ' + url + ' could not be dereferenced: ' + statusText,
'jsonld.InvalidUrl', {
code: 'loading document failed',
url,
Expand Down