correctly handle paths ending in /

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2025-12-05 16:30:05 +01:00
parent f12feeb440
commit 1fdd76b683

View File

@@ -272,7 +272,11 @@ func (rt Router) regexRouteMatcher(pattern string, target url.URL) bool {
}
func prefixRouteMatcher(prefix string, target url.URL) bool {
return strings.HasPrefix(path.Clean(target.Path), prefix) && prefix != "/"
cleanTarget := path.Clean(target.Path)
if strings.HasSuffix(target.Path, "/") {
cleanTarget += "/"
}
return strings.HasPrefix(cleanTarget, prefix) && prefix != "/"
}
func singleJoiningSlash(a, b string) string {