diff --git a/src/__tests__/providers/apple-books.test.ts b/src/__tests__/providers/apple-books.test.ts index b854bc68..6f4873f3 100644 --- a/src/__tests__/providers/apple-books.test.ts +++ b/src/__tests__/providers/apple-books.test.ts @@ -35,7 +35,7 @@ describe("getAppleBooks", () => { "categories": [ "Fiction", ], - "description": "<b>This #1 <i>New York Times </i>bestseller is a "bold and subversive retelling of the goddess's story" that brilliantly reimagines the life of Circe, formidable sorceress of The Odyssey (Alexandra Alter, <i>The</i><i>New York Times</i>).</b><br /><br /> In the house of Helios, god of the sun and mi…", + "description": "This #1 is a "bold and subversive retelling of the goddess's story" that brilliantly reimagines the life of Circe, formidable sorceress of The Odyssey (Alexandra Alter, TheNew York Times). In the house of Helios, god of the sun and mi…", "format": "audiobook", "identifier": "id1442351802", "identifiers": { @@ -83,7 +83,7 @@ describe("getAppleBooks", () => { "Literary Fiction", "Classics", ], - "description": "<b>This #1 <i>New York Times </i>bestseller is a "bold and subversive retelling of the goddess's story" that brilliantly reimagines the life of Circe, formidable sorceress of The Odyssey (Alexandra Alter, <i>The</i><i>New York Times</i>).</b><br /><br /> In the house of Helios, god of the sun and mi…", + "description": "This #1 is a "bold and subversive retelling of the goddess's story" that brilliantly reimagines the life of Circe, formidable sorceress of The Odyssey (Alexandra Alter, TheNew York Times). In the house of Helios, god of the sun and mi…", "format": "book", "identifier": "id1442351802", "identifiers": { @@ -134,7 +134,7 @@ describe("getAppleBooks", () => { { "authors": [], "categories": [], - "description": "<b>This #1 <i>New York Times </i>bestseller is a "bold and subversive retelling of the goddess's story" that brilliantly reimagines the life of Circe, formidable sorceress of The Odyssey (Alexandra Alter, <i>The</i><i>New York Times</i>).</b><br /><br /> In the house of Helios, god of the sun and mi…", + "description": "This #1 is a "bold and subversive retelling of the goddess's story" that brilliantly reimagines the life of Circe, formidable sorceress of The Odyssey (Alexandra Alter, TheNew York Times). In the house of Helios, god of the sun and mi…", "format": "book", "identifier": "id1442351802", "identifiers": { diff --git a/src/utils.ts b/src/utils.ts index 68150d61..3413fb14 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -32,6 +32,11 @@ export function sortByDate(array: NewBook[]): NewBook[] { export function formatDescription(str?) { if (!str) return ""; + // replace HTML entities + str = str.replace(/</g, "<").replace(/>/g, ">"); + str = str.replace(/"/g, '"'); + str = str.replace(/'/g, "'"); + // remove HTML tags str = str.replace(/<\/?[^>]+(>|$)/gm, "");