Add comments under posts and fix user profile

This commit is contained in:
Marco Realacci 2022-12-12 18:06:56 +01:00
parent 4c4481393d
commit e86526761c
13 changed files with 201 additions and 42 deletions

View file

@ -89,14 +89,14 @@ func (rt *_router) PostComment(w http.ResponseWriter, r *http.Request, ps httpro
}
// check if the comment is valid (should not contain newlines and at be between 5 and 255 characters)
stat, err := regexp.Match(`^[*]{5, 255}$`, []byte(request_body.Comment))
stat, err := regexp.Match(`^(.*)*`, []byte(request_body.Comment))
if err != nil {
helpers.SendInternalError(err, "Error matching regex", w, rt.baseLogger)
return
}
if !stat {
if !stat || len(request_body.Comment) < 5 || len(request_body.Comment) > 255 {
helpers.SendBadRequest(w, "Invalid comment", rt.baseLogger)
return
}