fix: explicitly reject non http protocols

This commit is contained in:
yanlong.wang 2024-04-18 15:35:06 +08:00
parent abc817e960
commit d4ca381c38
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -195,6 +195,12 @@ ${this.content}
let urlToCrawl;
try {
urlToCrawl = new URL(normalizeUrl(noSlashURL.trim(), { stripWWW: false, removeTrailingSlash: false, removeSingleSlash: false }));
if (urlToCrawl.protocol !== 'http:' && urlToCrawl.protocol !== 'https:') {
throw new ParamValidationError({
message: `Invalid protocol ${urlToCrawl.protocol}`,
path: 'url'
});
}
} catch (err) {
throw new ParamValidationError({
message: `${err}`,