fix
Build and Publish / Metadata (push) Successful in 10s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 2m15s

This commit is contained in:
mats committed 2026-09-20 11:39:20 +02:00
1 parent 645f923175
commit 2cf2cebf5c
20 files changed
+481 -51

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
package issues
import "testing"
func TestNormalizeRoutePrefixedIDs(t *testing.T) {
cases := map[string]string{
"/api/terminals/term_ab315d5ce24c4662b34a8ad998be79cf/ws": "/api/terminals/{id}/ws",
"/api/sessions/sess-9f2c41aa77/events": "/api/sessions/{id}/events",
"/api/skills": "/api/skills",
"/api/v2/settings": "/api/v2/settings",
"/api/user_settings": "/api/user_settings",
}
for in, want := range cases {
if got := NormalizeRoute(in); got != want {
t.Errorf("NormalizeRoute(%q) = %q, want %q", in, got, want)
}
}
}
+4 -1
View File
@@ -346,7 +346,7 @@ func NormalizeRoute(route string) string {
if part == "" {
continue
}
if uuidRe.MatchString(part) || hexIDRe.MatchString(part) || numRe.MatchString(part) {
if uuidRe.MatchString(part) || hexIDRe.MatchString(part) || numRe.MatchString(part) || prefixedIDRe.MatchString(part) {
parts[i] = "{id}"
}
}
@@ -623,6 +623,9 @@ var (
hexIDRe = regexp.MustCompile(`(?i)\b[0-9a-f]{8,}\b`)
httpStatusRe = regexp.MustCompile(`(?i)\bhttp\s+([1-5]\d{2})\b`)
numRe = regexp.MustCompile(`\b\d+\b`)
// A route segment that is a short prefix plus a long hex id (term_ab31…,
// sess-9f2c…): \b does not fire between "_" and a hex digit, so hexIDRe misses it.
prefixedIDRe = regexp.MustCompile(`(?i)^[a-z]{1,12}[_-][0-9a-f]{8,}$`)
spaceRe = regexp.MustCompile(`\s+`)
)