Skip to content

Commit

Permalink
Fix common issue with invalid JSON containing line breaks in strings
Browse files Browse the repository at this point in the history
  • Loading branch information
grahambates committed Dec 16, 2018
1 parent 7cfde98 commit 87255f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/parsers/jsonld-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function (html, config = {}) {

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

0 comments on commit 87255f3

Please sign in to comment.