Skip to content

Commit

Permalink
fix: scraper fails if matched domain has www
Browse files Browse the repository at this point in the history
resolves: #6 , #7
  • Loading branch information
towfiqi committed Dec 1, 2022
1 parent 7446b78 commit 38dc164
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const extractScrapedResult = (content:string, scraper_type:string): Searc
export const getSerp = (domain:string, result:SearchResult[]) : SERPObject => {
if (result.length === 0 || !domain) { return { postion: false, url: '' }; }
const foundItem = result.find((item) => {
const itemDomain = item.url.match(/^(?:https?:)?(?:\/\/)?([^/?]+)/i);
const itemDomain = item.url.replace('www.', '').match(/^(?:https?:)?(?:\/\/)?([^/?]+)/i);
return itemDomain && itemDomain.includes(domain);
});
return { postion: foundItem ? foundItem.position : 0, url: foundItem && foundItem.url ? foundItem.url : '' };
Expand Down

0 comments on commit 38dc164

Please sign in to comment.