From a22bad043920767fbc547e9e793157f5283770da Mon Sep 17 00:00:00 2001 From: KGFCH2 Date: Wed, 27 May 2026 03:37:59 +0530 Subject: [PATCH] fix: sanitize url validation and enhance api error parsing --- server.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 7febc16..da1c311 100644 --- a/server.js +++ b/server.js @@ -154,8 +154,12 @@ function createApp(options = {}) { app.post("/check", async (req, res) => { const userUrl = req.body.url; - if (!userUrl) { - return res.status(400).json({ error: "No URL provided" }); + if (!userUrl || typeof userUrl !== "string") { + return res.status(400).json({ error: "No URL provided or invalid format" }); + } + + if (userUrl.length > 2048) { + return res.status(400).json({ error: "URL exceeds maximum length of 2048 characters" }); } try {