Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seed parsing: return null if invalid url encountered in parseUrl to a… #349

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions util/seeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class ScopedSeed
constructor({url, scopeType, include, exclude = [], allowHash = false, depth = -1, sitemap = false, extraHops = 0} = {}) {
const parsedUrl = this.parseUrl(url);
if (!parsedUrl) {
logger.fatal(`Invalid Seed "${url}" - not a valid URL`);
logger.fatal(`Invalid Seed "${url}" specified, aborting crawl.`);
}
this.url = parsedUrl.href;
this.include = this.parseRx(include);
Expand Down Expand Up @@ -44,11 +44,12 @@ export class ScopedSeed
try {
parsedUrl = new URL(url.trim());
} catch (e) {
logger.warn("Invalid Seed - not a valid URL", {url, ...logDetails});
logger.warn("Invalid Page - not a valid URL", {url, ...logDetails});
return null;
}

if (parsedUrl.protocol !== "http:" && parsedUrl.protocol != "https:") {
logger.warn("Invalid Seed - URL must start with http:// or https://", {url, ...logDetails});
logger.warn("Invalid Page - URL must start with http:// or https://", {url, ...logDetails});
parsedUrl = null;
}

Expand Down