From 4bc6d73b1d6f4b3dd0ee54d2106e93476aa7e5e2 Mon Sep 17 00:00:00 2001 From: Jason Song <i@wolfogre.com> Date: Fri, 6 Jan 2023 14:28:16 +0800 Subject: [PATCH] fix: split and trim labels --- routers/web/shared/actions/runners.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/routers/web/shared/actions/runners.go b/routers/web/shared/actions/runners.go index b6f756a4ae..88a2118638 100644 --- a/routers/web/shared/actions/runners.go +++ b/routers/web/shared/actions/runners.go @@ -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 +}