Skip to content

Commit

Permalink
fix: 키워드 제목 비교 로직 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyongp committed Nov 14, 2023
1 parent 14c1175 commit 2d67c35
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/services/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@ export async function create(input: {
where: { blogId: blogId },
});

const matched = keywordMaps.find(({ keyword }) =>
input.title.includes(keyword),
);
const matched = keywordMaps.find((map) => {
const title = input.title
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase();
const keyword = map.keyword
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase();
return title.includes(keyword);
});

if (!matched) {
throw new HttpError("일치하는 키워드가 없습니다.", "BAD_REQUEST");
Expand Down

0 comments on commit 2d67c35

Please sign in to comment.