Skip to content

Commit

Permalink
✨ feat: html 특수 문자 변경 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
uuuo3o committed Nov 27, 2024
1 parent 2112990 commit c08e941
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions BE/src/news/news.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class NewsService {
};
}

@Cron('*/30 8-16 * * 1-5')
@Cron('*/1 8-16 * * 1-5')
async cronNewsData() {
await this.newsRepository.delete({ query: In(['증권', '주식']) });
await this.getNewsDataByQuery('주식');
Expand Down Expand Up @@ -76,13 +76,20 @@ export class NewsService {
return items.slice(0, 10).map((item) => {
const result = new NewsItemDataDto();

result.title = item.title.replace(/<\/?b>/g, '');
result.description = item.description.replace(/<\/?b>/g, '');
result.title = this.htmlEncode(item.title);
result.description = this.htmlEncode(item.description);
result.originallink = item.originallink;
result.pubDate = item.pubDate;
result.query = query;

return result;
});
}

private htmlEncode(value: string) {
return value
.replace(/<\/?b>/g, '')
.replace(/&quot;/g, '"')
.replace(/&amp;/g, '&');
}
}

0 comments on commit c08e941

Please sign in to comment.