Skip to content

Commit

Permalink
Merge pull request #404 from extractus/8.0.12
Browse files Browse the repository at this point in the history
v8.0.12
  • Loading branch information
ndaidong authored Oct 15, 2024
2 parents 588f6ff + b7de5c4 commit 39616dc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "8.0.11",
"version": "8.0.12",
"name": "@extractus/article-extractor",
"description": "To extract main article from given URL",
"homepage": "https://github.com/extractus/article-extractor",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/extractLdSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) => {
Expand Down
21 changes: 21 additions & 0 deletions test-data/regular-article-json-ld.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@
<meta property="og:title" content="Article title here">
<meta property="og:url" content="https://somewhere.com/path/to/article-title-here">

<script type="application/ld+json">
[{ "@context": "https://schema.org",
"@type": "SomeRandomType",
"author": "Alice",
"keywords": "keyword1, keyword2, keyword3",
"keywords_with_line_breaks": "keyword1, keyword2,
keyword3",
"datePublished": "23\/01\/2014",
"dateCreated": "23\/01\/2014"
},
{ "@context": "https://schema.org",
"@type": "AnotherRandomType",
"author": {
"@type": "Person",
"name": "Alice"
},
"keywords": "keyword1, keyword2, keyword3",
"keywords_with_line_breaks": "keyword1, keyword2,
keyword3"
}]
</script>

<script type="application/ld+json">
{ "@context": "https://schema.org",
Expand Down

0 comments on commit 39616dc

Please sign in to comment.