Skip to content

Commit f7f84ee

Browse files
committed
ld: better fix "Cannot read properties of null"
1 parent a8c8cfb commit f7f84ee

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/utils.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,7 @@ export function parseJSONSource(text, decode) {
412412
return JSON.parse(s);
413413
};
414414

415-
export function parseLDSource(ld, decode, uri) {
416-
417-
if (!ld) return;
418-
419-
var ldParsed;
415+
export function parseLDSource(ld, decode, uri) {
420416

421417
if (typeof ld === 'string') {
422418
try {
@@ -427,14 +423,18 @@ export function parseLDSource(ld, decode, uri) {
427423
}
428424
}
429425

430-
if (ld && !(ld instanceof Array)) {
426+
if (!ld) return;
427+
428+
if (!(ld instanceof Array)) {
431429
if (!ld['@type'] && ld['@graph'] && Array.isArray(ld['@graph'])) {
432430
ld = ld['@graph'];
433431
} else {
434432
ld = [ld];
435433
}
436434
}
437435

436+
var ldParsed;
437+
438438
const addObject = function(obj) {
439439

440440
const pushObj = function(id, obj) {

0 commit comments

Comments
 (0)