mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 20:27:23 +00:00
Trim whitespace from tag and keyword inputs in tag creation
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"nysoure/server/model"
|
"nysoure/server/model"
|
||||||
"nysoure/server/service"
|
"nysoure/server/service"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func handleCreateTag(c fiber.Ctx) error {
|
func handleCreateTag(c fiber.Ctx) error {
|
||||||
@@ -12,6 +13,7 @@ func handleCreateTag(c fiber.Ctx) error {
|
|||||||
if tag == "" {
|
if tag == "" {
|
||||||
return model.NewRequestError("name is required")
|
return model.NewRequestError("name is required")
|
||||||
}
|
}
|
||||||
|
tag = strings.TrimSpace(tag)
|
||||||
uid, ok := c.Locals("uid").(uint)
|
uid, ok := c.Locals("uid").(uint)
|
||||||
if !ok {
|
if !ok {
|
||||||
return model.NewUnAuthorizedError("You must be logged in to create a tag")
|
return model.NewUnAuthorizedError("You must be logged in to create a tag")
|
||||||
@@ -32,6 +34,7 @@ func handleSearchTag(c fiber.Ctx) error {
|
|||||||
if keyword == "" {
|
if keyword == "" {
|
||||||
return model.NewRequestError("Keyword is required")
|
return model.NewRequestError("Keyword is required")
|
||||||
}
|
}
|
||||||
|
keyword = strings.TrimSpace(keyword)
|
||||||
tags, err := service.SearchTag(keyword)
|
tags, err := service.SearchTag(keyword)
|
||||||
if tags == nil {
|
if tags == nil {
|
||||||
tags = []model.TagView{}
|
tags = []model.TagView{}
|
||||||
|
Reference in New Issue
Block a user