Skip to content

Commit

Permalink
More changes suggested by @dlongley.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Jan 20, 2020
1 parent 6a92eac commit c1c0221
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/documentLoaders/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ module.exports = ({

// handle Link Header (avoid unsafe header warning by existence testing)
let linkHeader;
if(REGEX_LINK_HEADER.test(req.getAllResponseHeaders()) &&
contentType !== 'application/ld+json') {
if(contentType !== 'application/ld+json' &&
REGEX_LINK_HEADER.test(req.getAllResponseHeaders())) {
linkHeader = req.getResponseHeader('Link');
}
if(linkHeader && contentType !== 'application/ld+json') {
Expand Down
17 changes: 9 additions & 8 deletions lib/jsonld.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,16 +935,17 @@ jsonld.get = async function(url, options) {
}
} catch(e) {
if(e.name === 'jsonld.InvalidScriptElement') {
// pass error detected in HTML decode
throw (e);
} else {
throw new JsonLdError(
'Could not retrieve a JSON-LD document from the URL.',
'jsonld.LoadDocumentError', {
code: 'loading document failed',
cause: e,
remoteDoc
});
}
// otherwise, general loading error
throw new JsonLdError(
'Could not retrieve a JSON-LD document from the URL.',
'jsonld.LoadDocumentError', {
code: 'loading document failed',
cause: e,
remoteDoc
});
}

return remoteDoc;
Expand Down

0 comments on commit c1c0221

Please sign in to comment.