Skip to content

Commit d1c1290

Browse files
committed
More changes suggested by @dlongley.
1 parent 0c76b00 commit d1c1290

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/documentLoaders/xhr.js

+2-2
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

+9-8
Original file line numberDiff line numberDiff line change
@@ -935,16 +935,17 @@ jsonld.get = async function(url, options) {
935935
}
936936
} catch(e) {
937937
if(e.name === 'jsonld.InvalidScriptElement') {
938+
// pass error detected in HTML decode
938939
throw (e);
939-
} else {
940-
throw new JsonLdError(
941-
'Could not retrieve a JSON-LD document from the URL.',
942-
'jsonld.LoadDocumentError', {
943-
code: 'loading document failed',
944-
cause: e,
945-
remoteDoc
946-
});
947940
}
941+
// otherwise, general loading error
942+
throw new JsonLdError(
943+
'Could not retrieve a JSON-LD document from the URL.',
944+
'jsonld.LoadDocumentError', {
945+
code: 'loading document failed',
946+
cause: e,
947+
remoteDoc
948+
});
948949
}
949950

950951
return remoteDoc;

0 commit comments

Comments
 (0)