Skip to content

Commit 87255f3

Browse files
committed
Fix common issue with invalid JSON containing line breaks in strings
1 parent 7cfde98 commit 87255f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/parsers/jsonld-parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function (html, config = {}) {
77

88
$html('script[type="application/ld+json"]').each((index, item) => {
99
try {
10-
const json = item.children[0].data.trim().replace(/;$/, '')
10+
const json = item.children[0].data.trim().replace(/[\r\n]/, ' ').replace(/;$/, '')
1111
let parsedJSON = JSON.parse(json)
1212
if (!Array.isArray(parsedJSON)) {
1313
parsedJSON = [parsedJSON]

0 commit comments

Comments
 (0)