Bugfix/Web Scraper Limit (#2083)

fix when limit set to 0, selectedLinks sliced to become empty
This commit is contained in:
Henry Heng
2024-04-02 11:14:04 +01:00
committed by GitHub
parent dad30472b6
commit b9b0c9d227
3 changed files with 3 additions and 3 deletions
@@ -132,7 +132,7 @@ class Cheerio_DocumentLoaders implements INode {
else if (limit < 0) throw new Error('Limit cannot be less than 0')
const pages: string[] =
selectedLinks && selectedLinks.length > 0
? selectedLinks.slice(0, limit)
? selectedLinks.slice(0, limit === 0 ? undefined : limit)
: relativeLinksMethod === 'webCrawl'
? await webCrawl(url, limit)
: await xmlScrape(url, limit)
@@ -173,7 +173,7 @@ class Playwright_DocumentLoaders implements INode {
else if (limit < 0) throw new Error('Limit cannot be less than 0')
const pages: string[] =
selectedLinks && selectedLinks.length > 0
? selectedLinks.slice(0, limit)
? selectedLinks.slice(0, limit === 0 ? undefined : limit)
: relativeLinksMethod === 'webCrawl'
? await webCrawl(url, limit)
: await xmlScrape(url, limit)
@@ -174,7 +174,7 @@ class Puppeteer_DocumentLoaders implements INode {
else if (limit < 0) throw new Error('Limit cannot be less than 0')
const pages: string[] =
selectedLinks && selectedLinks.length > 0
? selectedLinks.slice(0, limit)
? selectedLinks.slice(0, limit === 0 ? undefined : limit)
: relativeLinksMethod === 'webCrawl'
? await webCrawl(url, limit)
: await xmlScrape(url, limit)