same-domain strategy stops filtering after a cross-domain redirect
Was discovered together with #3920 When a request redirects to a different registrable domain, resolveBaseUrlForEnqueueLinksFiltering returns undefined on purpose, and the comment says this will make enqueueLinks enqueue nothing. The opposite happens: with no baseUrl the strategy patterns are never built, and an empty pattern list means "no filtering" further down in shared.ts. The domain filter disappears and every link on the page is enqueued, third party ones included.
Example: https://sloncek.net/ redirects to https://www.sloncek.si/. Different registrable domains, so the filter is gone on the first page and the footer links to linkedin.com and facebook.com get queued. Once the crawler is on a LinkedIn page, url and loadedUrl match again, same-domain resolves against linkedin.com, and the crawl expands there unchecked.
Only triggers when strategy: 'same-domain' is set explicitly. same-hostname and same-origin always get a defined origin back.
Proposed fix
Returning the original request origin:
https://github.com/apify/crawlee/blob/master/packages/core/src/enqueue_links/enqueue_links.ts#L502
- return undefined;
+ return originalUrlOrigin;
Happy to open a PR if the approach looks right.