Skip to content

Commit 880076a

Browse files
committed
More changes suggested by @dlongley.
1 parent 05797c2 commit 880076a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/documentLoaders/xhr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ module.exports = ({
8989

9090
// handle Link Header (avoid unsafe header warning by existence testing)
9191
let linkHeader;
92-
if(REGEX_LINK_HEADER.test(req.getAllResponseHeaders()) &&
93-
contentType !== 'application/ld+json') {
92+
if(contentType !== 'application/ld+json' &&
93+
REGEX_LINK_HEADER.test(req.getAllResponseHeaders())) {
9494
linkHeader = req.getResponseHeader('Link');
9595
}
9696
if(linkHeader && contentType !== 'application/ld+json') {

lib/jsonld.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -943,16 +943,17 @@ jsonld.get = async function(url, options) {
943943
}
944944
} catch(e) {
945945
if(e.name === 'jsonld.InvalidScriptElement') {
946+
// pass error detected in HTML decode
946947
throw (e);
947-
} else {
948-
throw new JsonLdError(
949-
'Could not retrieve a JSON-LD document from the URL.',
950-
'jsonld.LoadDocumentError', {
951-
code: 'loading document failed',
952-
cause: e,
953-
remoteDoc
954-
});
955948
}
949+
// otherwise, general loading error
950+
throw new JsonLdError(
951+
'Could not retrieve a JSON-LD document from the URL.',
952+
'jsonld.LoadDocumentError', {
953+
code: 'loading document failed',
954+
cause: e,
955+
remoteDoc
956+
});
956957
}
957958

958959
return remoteDoc;

0 commit comments

Comments
 (0)