Skip to content

Commit

Permalink
一部のページでクローラーがエラーになるバグを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-20 committed Jan 20, 2024
1 parent a23862a commit 48af745
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/lib/src/crawler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ export interface ArticleResponse {
export const fetchArticle = async (
url: string,
): Promise<ArticleResponse | null> => {
const { host } = new URL(url);

if (host === 'note.com') {
if (/https?:\/\/note.com\/[^/]+\/n\/[^/]+/.exec(url)) {
return fetchArticleFromNote(url);
}

if (host === 'qiita.com') {
if (/https?:\/\/qiita.com\/[^/]+\/items\/[^/]+/.exec(url)) {
return fetchArticleFromQiita(url);
}

if (host === 'zenn.dev') {
if (/https?:\/\/zenn.dev\/[^/]+\/articles\/[^/]+/.exec(url)) {
return fetchArticleFromZenn(url);
}

Expand Down

0 comments on commit 48af745

Please sign in to comment.