fix: urls handle empty strings
This commit is contained in:
parent
a481c0ee5e
commit
dbac6e8918
1 changed files with 2 additions and 0 deletions
|
@ -20,6 +20,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
if (!req.body) return res.badRequest('no body');
|
||||
if (!req.body.url) return res.badRequest('no url');
|
||||
|
||||
if (req.body.vanity && req.body.vanity.trim().length === 0) return res.badRequest('vanity is empty');
|
||||
|
||||
const maxUrlViews = req.headers['max-views'] ? Number(req.headers['max-views']) : null;
|
||||
if (isNaN(maxUrlViews)) return res.badRequest('invalid max views (invalid number)');
|
||||
if (maxUrlViews < 0) return res.badRequest('invalid max views (max views < 0)');
|
||||
|
|
Loading…
Reference in a new issue