Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 11, 01:00 UTC
caddyhttp: correct path matcher doc on bare trailing wildcards (#8006)
Nguyen Thanh Dat committed
Nov 3, 2026 at 13:19 UTC
0759b29fe00c7beb0af1a8c949e68643a3377431
2 files changed
+21
-7
modules/caddyhttp/matchers.go
+4
-7
@@ -95,13 +95,10 @@ type (
95
//
96
// Even though wildcards (`*`) operate in the normalized space, the special
97
// escaped wildcard (`%*`), which is not a valid escape sequence, may be
98
- // used in place of a span that should NOT be decoded; that is, `/bands/%*`
99
- // will match `/bands/AC%2fDC` whereas `/bands/*` will not.
100
- //
101
- // Even though path matching is done in normalized space, the special
102
- // wildcard `%*` may be used in place of a span that should NOT be decoded;
103
- // that is, `/bands/%*/` will match `/bands/AC%2fDC/` whereas `/bands/*/`
104
- // will not.
98
+ // used in place of a span that should NOT be decoded; that is, `/bands/%*/`
99
+ // will match `/bands/AC%2fDC/` whereas `/bands/*/` will not. Note that a
100
+ // pattern ending in a bare trailing wildcard, such as `/bands/*`, is a
101
+ // prefix match in normalized space, so it does match `/bands/AC%2fDC`.
102
//
103
// This matcher is fast, so it does not support regular expressions or
104
// capture groups. For slower but more powerful matching, use the
modules/caddyhttp/matchers_test.go
+17
@@ -397,6 +397,23 @@ func TestPathMatcher(t *testing.T) {
397
input: "/bands/AC%2FDC",
398
expect: true,
399
},
400
+ {
401
+ // a lone trailing wildcard is a fast prefix match in normalized
402
+ // space, so it does match an encoded separator
403
+ match: MatchPath{"/bands/*"},
404
+ input: "/bands/AC%2FDC",
405
+ expect: true,
406
+ },
407
+ {
408
+ match: MatchPath{"/bands/%*/"},
409
+ input: "/bands/AC%2FDC/",
410
+ expect: true,
411
+ },
412
+ {
413
+ match: MatchPath{"/bands/*/"},
414
+ input: "/bands/AC%2FDC/",
415
+ expect: false, // because * operates in normalized space
416
+ },
417
{
418
match: MatchPath{"/foo%2fbar/baz"},
419
input: "/foo%2Fbar/baz",