feat(router): add literal colon support (#1432) (#2857)

This commit is contained in:
wssccc
2024-06-01 13:44:57 +08:00
committed by GitHub
parent 334160bab7
commit 4621b7ac98
4 changed files with 83 additions and 1 deletions
+12
View File
@@ -262,7 +262,19 @@ walk:
// Returns -1 as index, if no wildcard was found.
func findWildcard(path string) (wildcard string, i int, valid bool) {
// Find start
escapeColon := false
for start, c := range []byte(path) {
if escapeColon {
escapeColon = false
if c == ':' {
continue
}
panic("invalid escape string in path '" + path + "'")
}
if c == '\\' {
escapeColon = true
continue
}
// A wildcard starts with ':' (param) or '*' (catch-all)
if c != ':' && c != '*' {
continue