From 33063f992a8fff4af9e8cdfa54317c61f7727be3 Mon Sep 17 00:00:00 2001 From: maddalax Date: Mon, 30 Sep 2024 20:34:15 -0500 Subject: [PATCH] fix dynamic paths for chi --- cli/htmgo/tasks/astgen/entry.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cli/htmgo/tasks/astgen/entry.go b/cli/htmgo/tasks/astgen/entry.go index a057724..e11ef0b 100644 --- a/cli/htmgo/tasks/astgen/entry.go +++ b/cli/htmgo/tasks/astgen/entry.go @@ -293,6 +293,17 @@ func formatRoute(path string) string { path = strings.ReplaceAll(path, "_", "/") path = strings.ReplaceAll(path, ".", "/") path = strings.ReplaceAll(path, "\\", "/") + + parts := strings.Split(path, "/") + + for i, part := range parts { + if strings.HasPrefix(part, ":") { + parts[i] = fmt.Sprintf("{%s}", part[1:]) + } + } + + path = strings.Join(parts, "/") + if path == "" { return "/" }