Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: align tag update slug #923

Merged
merged 2 commits into from Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions internal/service/tag_common/tag_common.go
Expand Up @@ -321,10 +321,10 @@ func (ts *TagCommonService) AddTag(ctx context.Context, req *schema.AddTagReq) (
if exist {
return nil, errors.BadRequest(reason.TagAlreadyExist)
}
SlugName := strings.ReplaceAll(req.SlugName, " ", "-")
SlugName = strings.ToLower(SlugName)
slugName := strings.ReplaceAll(req.SlugName, " ", "-")
slugName = strings.ToLower(slugName)
tagInfo := &entity.Tag{
SlugName: SlugName,
SlugName: slugName,
DisplayName: req.DisplayName,
OriginalText: req.OriginalText,
ParsedText: req.ParsedText,
Expand Down Expand Up @@ -837,14 +837,19 @@ func (ts *TagCommonService) UpdateTag(ctx context.Context, req *schema.UpdateTag
if !exist {
return errors.BadRequest(reason.TagNotFound)
}

//Adding equivalent slug formatting for tag update
slugName := strings.ReplaceAll(req.SlugName, " ", "-")
slugName = strings.ToLower(slugName)

//If the content is the same, ignore it
if tagInfo.OriginalText == req.OriginalText &&
tagInfo.DisplayName == req.DisplayName &&
tagInfo.SlugName == req.SlugName {
tagInfo.SlugName == slugName {
return nil
}

tagInfo.SlugName = req.SlugName
tagInfo.SlugName = slugName
tagInfo.DisplayName = req.DisplayName
tagInfo.OriginalText = req.OriginalText
tagInfo.ParsedText = req.ParsedText
Expand Down