Skip to content

Commit

Permalink
Update types and spec char handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kfaubel committed Jan 5, 2022
1 parent f477412 commit 487aadd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion msnbc-top-headlines.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "MSNBC"
},
"author": "MSNBC",
"title": "Teen tennis star Coco Gauff tests positive for Covid, will sit out Tokyo Olympics",
"title": "This is my test title with &lt;b&gt;: '<b>' and &lt;/b&gt;: '</b>' and also &lt;em&gt;: '<em>' and &lt;/em&gt; : '</em>' and ampersand: '&amp;', gt '&gt;' and lt '&lt;'",
"description": "Tennis player Coco Gauff has tested positive for Covid-19 and will not be competing in the Tokyo Olympics, where she was expected to lead Team USA",
"url": "https://www.nbcnews.com/news/sports/teen-tennis-star-coco-gauff-tests-positive-covid-will-sit-n1274319",
"urlToImage": "https://s.yimg.com/os/creatr-uploaded-images/2021-08/bedfaf90-0763-11ec-af53-60d3362737c0",
Expand Down
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"pureimage": "^0.3.5"
},
"devDependencies": {
"@types/axios": "^0.14.0",
"@types/he": "^1.1.2",
"@types/jpeg-js": "^0.3.7",
"@types/node": "^12.20.19",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
Expand Down
20 changes: 10 additions & 10 deletions src/NewsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ export class NewsData {
}

private fixString(inStr: string): string {
return he.decode(inStr);
// let outStr = inStr;
// outStr = outStr.replace(/&amp;/g, "&");
// outStr = outStr.replace(/&lt;/g, "<");
// outStr = outStr.replace(/&gt;/g, ">");
// outStr = outStr.replace(/<b>/g, "");
// outStr = outStr.replace("</b>", ""); // TODO fix - (/</b>/g, "")
// outStr = outStr.replace(/&#39;/g, "'");
// outStr = outStr.replace(/&apos;/g, "'");

// return outStr;
let outStr = inStr;

outStr = outStr.replace(/<b>/g, "");
outStr = outStr.replace(/<\/b>/g, "");
//outStr = outStr.replace("</b>", ""); // TODO fix - (/</b>/g, "")
outStr = outStr.replace(/<em>/g, "");
outStr = outStr.replace(/<\/em>/g, "");
//outStr = outStr.replace("</em>", "");

return he.decode(outStr);
}

public async getData(source: string, key: string): Promise<Array<NewsItem> | null> {
Expand Down

0 comments on commit 487aadd

Please sign in to comment.