Skip to content

Commit

Permalink
fix(route): prevent backspace character from breaking JSON parsing in…
Browse files Browse the repository at this point in the history
… udn (DIYgod#13220)

* fix(route): prevent backspace character from breaking JSON parsing in udn.

* Update breaking-news.js
  • Loading branch information
dzx-dzx authored Sep 6, 2023
1 parent 8806b7a commit caa8800
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/v2/udn/breaking-news.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = async (ctx) => {
}

const $ = cheerio.load(result.data);
const metadata = $('script[type="application/ld+json"]').eq(0).text().trim();
const metadata = $('script[type="application/ld+json"]').eq(0).text().trim().replaceAll(/[\b]/g, "");
const data = metadata.startsWith('[') ? JSON.parse(metadata)[0] : JSON.parse(metadata);
// e.g. https://udn.com/news/story/7331/6576320
const content = $('.article-content__editor');
Expand Down

0 comments on commit caa8800

Please sign in to comment.