Merge pull request #4958 from flycash/dev1.x

fix 4946: router /aa/:name can match /aa.xml/aa.xml
This commit is contained in:
Ming Deng 2022-05-23 20:48:39 +08:00 committed by GitHub
commit 228576173a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -341,7 +341,7 @@ func (t *Tree) match(treePattern string, pattern string, wildcardValues []string
if runObject == nil && len(t.fixrouters) > 0 {
// Filter the .json .xml .html extension
for _, str := range allowSuffixExt {
if strings.HasSuffix(seg, str) && strings.HasSuffix(treePattern, seg) {
if strings.HasSuffix(seg, str) && pattern == "" {
for _, subTree := range t.fixrouters {
// strings.HasSuffix(treePattern, seg) avoid cases: /aaa.html/bbb could access /aaa/bbb
if subTree.prefix == seg[:len(seg)-len(str)] {