fix: split and trim labels

This commit is contained in:
Jason Song 2023-01-06 14:28:16 +08:00
parent 05c08ec246
commit 4bc6d73b1d
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5

View File

@ -130,7 +130,7 @@ func RunnerDetailsEditPost(ctx *context.Context, runnerID, ownerID, repoID int64
form := web.GetForm(ctx).(*forms.EditRunnerForm)
runner.Description = form.Description
runner.CustomLabels = strings.Split(form.CustomLabels, ",")
runner.CustomLabels = splitLabels(form.CustomLabels)
err = actions_model.UpdateRunner(ctx, runner, "description", "custom_labels")
if err != nil {
@ -182,3 +182,11 @@ func RunnerDeletePost(ctx *context.Context, runnerID int64,
ctx.Flash.Success(ctx.Tr("runners.delete_runner_success"))
ctx.Redirect(successRedirectTo)
}
func splitLabels(s string) []string {
labels := strings.Split(s, ",")
for i, v := range labels {
labels[i] = strings.TrimSpace(v)
}
return labels
}