This commit is contained in:
Nicolas 2024-09-10 06:53:30 -03:00
commit a7406031fa
2 changed files with 9 additions and 2 deletions

View File

@ -30,7 +30,14 @@ export const url = z.preprocess(
"URL must have a valid top-level domain or be a valid path" "URL must have a valid top-level domain or be a valid path"
) )
.refine( .refine(
(x) => checkUrl(x as string), (x) => {
try {
checkUrl(x as string)
return true;
} catch (_) {
return false;
}
},
"Invalid URL" "Invalid URL"
) )
.refine( .refine(

View File

@ -83,7 +83,7 @@ function idempotencyMiddleware(req: Request, res: Response, next: NextFunction)
} }
function blocklistMiddleware(req: Request, res: Response, next: NextFunction) { function blocklistMiddleware(req: Request, res: Response, next: NextFunction) {
if (req.body.url && isUrlBlocked(req.body.url)) { if (typeof req.body.url === "string" && isUrlBlocked(req.body.url)) {
if (!res.headersSent) { if (!res.headersSent) {
return res.status(403).json({ success: false, error: "URL is blocked. Firecrawl currently does not support social media scraping due to policy restrictions." }); return res.status(403).json({ success: false, error: "URL is blocked. Firecrawl currently does not support social media scraping due to policy restrictions." });
} }