From 64c1c0cf140fb663a4bd08bc2ebc845022f87081 Mon Sep 17 00:00:00 2001 From: andremacola Date: Tue, 15 Oct 2024 10:53:38 -0300 Subject: [PATCH 1/3] fix: Cannot read properties of undefined in ld+json --- src/utils/extractLdSchema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/extractLdSchema.js b/src/utils/extractLdSchema.js index b74ebd8..6077331 100644 --- a/src/utils/extractLdSchema.js +++ b/src/utils/extractLdSchema.js @@ -56,7 +56,7 @@ export default (document, entry) => { ldSchemas.forEach(ldSchema => { const ldJson = parseJson(ldSchema.textContent.replace(/[\n\r\t]/g, '')) - const isAllowedLdJsonType = typeSchemas.includes(ldJson['@type'].toLowerCase()) + const isAllowedLdJsonType = typeSchemas.includes(ldJson['@type']?.toLowerCase()) if (ldJson && isAllowedLdJsonType) { Object.entries(attributeLists).forEach(([key, attr]) => { From eb52a787a67de2db4c39d9fa07ae44c8c0f79fde Mon Sep 17 00:00:00 2001 From: andremacola Date: Tue, 15 Oct 2024 11:16:51 -0300 Subject: [PATCH 2/3] fix: more tests on ld+json --- test-data/regular-article-json-ld.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test-data/regular-article-json-ld.html b/test-data/regular-article-json-ld.html index 2d44166..805abe7 100644 --- a/test-data/regular-article-json-ld.html +++ b/test-data/regular-article-json-ld.html @@ -12,6 +12,27 @@ +