Skip to content

Commit 96fff53

Browse files
committed
bug: location: only append astrisk to matcher if the argument path does not end in astrisk
1 parent cae2261 commit 96fff53

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

location.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ nextDirective:
4545
It basically terminates location block matching.
4646
https://www.keycdn.com/support/nginx-location-directive
4747
*/
48-
matchConfMap["path"] = caddyhttp.MatchPath([]string{dir.Param(2) + "*"})
48+
p := dir.Param(2)
49+
if !strings.HasSuffix(p, "*") {
50+
p += "*"
51+
}
52+
matchConfMap["path"] = caddyhttp.MatchPath([]string{p})
4953
warns = append(warns, caddyconfig.Warning{
5054
File: dir.File,
5155
Line: dir.Line,
@@ -64,7 +68,11 @@ nextDirective:
6468
continue nextDirective
6569
}
6670
// append wild character because nginx treat naked path matchers as prefix matchers
67-
matchConfMap["path"] = caddyhttp.MatchPath([]string{dir.Param(1) + "*"})
71+
p := dir.Param(1)
72+
if !strings.HasSuffix(p, "*") {
73+
p += "*"
74+
}
75+
matchConfMap["path"] = caddyhttp.MatchPath([]string{p})
6876
}
6977
subsubroutes, warns, err := ss.locationContext(matchConfMap, dir.Block)
7078
if err != nil || len(subsubroutes) == 0 {

0 commit comments

Comments
 (0)