Skip to content

Commit

Permalink
fix: calling enqueueLinks in browser crawler on page without any links
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed Jul 20, 2022
1 parent 3e721c6 commit 385ca27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/browser-crawler/src/internals/browser-crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ export async function browserCrawlerEnqueueLinks({
*/
// eslint-disable-next-line @typescript-eslint/ban-types
async function extractUrlsFromPage(page: { $$eval: Function }, selector: string, baseUrl?: string): Promise<string[]> {
const urls = await page.$$eval(selector, (linkEls: HTMLLinkElement[]) => linkEls.map((link) => link.getAttribute('href')).filter((href) => !!href));
const urls = await page.$$eval(selector, (linkEls: HTMLLinkElement[]) => linkEls.map((link) => link.getAttribute('href')).filter((href) => !!href)) ?? [];

return urls.map((href: string) => {
// Throw a meaningful error when only a relative URL would be extracted instead of waiting for the Request to fail later.
Expand Down

0 comments on commit 385ca27

Please sign in to comment.