diff --git a/lib/jsonld.js b/lib/jsonld.js index 8583b90f..1d1a6d32 100644 --- a/lib/jsonld.js +++ b/lib/jsonld.js @@ -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 {