Skip to content

Commit

Permalink
Merge pull request #116 from forestWinger/main
Browse files Browse the repository at this point in the history
创建tag时去除前后空格
  • Loading branch information
JingYiJun authored Oct 23, 2023
2 parents 46bcb95 + f5c1868 commit 42f1eea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions apis/tag/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func CreateTag(c *fiber.Ctx) error {
}

// bind and create tag
body.Name = strings.TrimSpace(body.Name)
tag.Name = body.Name
result := DB.Where("name = ?", body.Name).FirstOrCreate(&tag)
if result.RowsAffected == 0 {
Expand Down
1 change: 1 addition & 0 deletions models/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func FindOrCreateTags(tx *gorm.DB, user *User, names []string) (Tags, error) {

newTags := make(Tags, 0)
for _, name := range names {
name = strings.TrimSpace(name)
if !slices.ContainsFunc(existTagName, func(s string) bool {
return strings.EqualFold(s, name)
}) {
Expand Down

0 comments on commit 42f1eea

Please sign in to comment.