From 1f737277b28927f9ab82e9e49d931f10e757a2ca Mon Sep 17 00:00:00 2001 From: Akif9748 Date: Sat, 27 Aug 2022 14:20:14 +0300 Subject: [PATCH] regex for avatars --- routes/register.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/register.js b/routes/register.js index 0ec89f4..4fce31a 100644 --- a/routes/register.js +++ b/routes/register.js @@ -23,7 +23,7 @@ app.post("/", rateLimit({ const user2 = new UserModel({ name: req.body.username }) - if (avatar) user2.avatar = avatar; + if (avatar&&/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g.test(avatar)) user2.avatar = avatar; await user2.takeId() await user2.save();