fix dynamic paths for chi

This commit is contained in:
maddalax 2024-09-30 20:34:15 -05:00
parent d2072fe777
commit 33063f992a

View file

@ -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 "/"
}