Skip to content

Commit

Permalink
Error when loading HTML and no script element exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Apr 9, 2020
1 parent 66a2092 commit 11b68b9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/jsonld.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,14 @@ jsonld.get = async function(url, options) {
});
}
if(frag || !options.extractAllScripts) {
if(!remoteDoc.document[0]) {
throw new JsonLdError(
`No script tag found.`,
'jsonld.InvalidScriptElement', {
code: 'loading document failed',
remoteDoc
});
}
remoteDoc.document = remoteDoc.document[0];
}
} else {
Expand Down

0 comments on commit 11b68b9

Please sign in to comment.