From 04148e14db21550fccd8745baf3897726c5a9f99 Mon Sep 17 00:00:00 2001 From: Tink bot Date: Tue, 19 May 2026 07:51:54 +0000 Subject: [PATCH] feat(api): lowercase project identifier before by-index lookup Normalises the input side so GitHub-style references like "TEST1-42" and "test1-42" resolve to the same project. The SQL comparison itself remains case-sensitive for now; case-insensitive matching on the column will be addressed separately. --- pkg/routes/resolve_project.go | 3 ++- pkg/webtests/task_by_index_test.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/routes/resolve_project.go b/pkg/routes/resolve_project.go index 26ec83341..7847b2d53 100644 --- a/pkg/routes/resolve_project.go +++ b/pkg/routes/resolve_project.go @@ -19,6 +19,7 @@ package routes import ( "net/http" "strconv" + "strings" "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/models" @@ -44,7 +45,7 @@ func ResolveProjectIdentifier() echo.MiddlewareFunc { s := db.NewSession() project := &models.Project{} - has, err := s.Where("identifier = ?", raw).Get(project) + has, err := s.Where("identifier = ?", strings.ToLower(raw)).Get(project) _ = s.Close() if err != nil { return err diff --git a/pkg/webtests/task_by_index_test.go b/pkg/webtests/task_by_index_test.go index dac04fbe4..8b2816297 100644 --- a/pkg/webtests/task_by_index_test.go +++ b/pkg/webtests/task_by_index_test.go @@ -57,6 +57,12 @@ func TestTaskByProjectIndex(t *testing.T) { assert.Contains(t, rec.Body.String(), `"id":1`) }) + t.Run("identifier match is case-insensitive on the input", func(t *testing.T) { + rec := do("/api/v1/projects/TEST1/tasks/by-index/1") + assert.Equal(t, http.StatusOK, rec.Code) + assert.Contains(t, rec.Body.String(), `"id":1`) + }) + t.Run("unknown project identifier returns 404", func(t *testing.T) { rec := do("/api/v1/projects/does-not-exist/tasks/by-index/1") assert.Equal(t, http.StatusNotFound, rec.Code)