diff --git a/lib/context.js b/lib/context.js index bb33d82f..7f3b73ac 100644 --- a/lib/context.js +++ b/lib/context.js @@ -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.', @@ -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; } @@ -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); })); } } diff --git a/lib/documentLoaders/node.js b/lib/documentLoaders/node.js index a00a332c..e429a0d2 100644 --- a/lib/documentLoaders/node.js +++ b/lib/documentLoaders/node.js @@ -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,