mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
fix prev commit
This commit is contained in:
parent
a431a1c7d2
commit
23741e7209
|
@ -67,7 +67,7 @@ func TestRouterWildcardDifferentPrefixPath(t *testing.T) {
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
testTheRoutes(t, tt, false)
|
testTheRoutes(t, tt, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRouterWildcardAndStatic(t *testing.T) {
|
func TestRouterWildcardAndStatic(t *testing.T) {
|
||||||
|
@ -117,7 +117,7 @@ func TestRouterWildcardRootMany(t *testing.T) {
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
testTheRoutes(t, tt, false)
|
testTheRoutes(t, tt, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRouterWildcardRootManyAndRootStatic(t *testing.T) {
|
func TestRouterWildcardRootManyAndRootStatic(t *testing.T) {
|
||||||
|
|
|
@ -127,22 +127,27 @@ func (tr *trie) insert(path string, route context.RouteReadOnly, handlers contex
|
||||||
|
|
||||||
var paramKeys []string
|
var paramKeys []string
|
||||||
|
|
||||||
for i, s := range input {
|
for _, s := range input {
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
c := s[0]
|
c := s[0]
|
||||||
|
|
||||||
if len(s)-1 > i+1 && s[i+1] != '/' { // has next character and it's not slash.
|
if len(s) > 1 { // has more than one character.
|
||||||
// get the next character, if not slash then this is a parameter.
|
// get the next character, should be the name of the parameter.
|
||||||
// E.g:
|
// E.g:
|
||||||
// If /test/:param (or /test/*param) then it's dynamic.
|
// If /test/:param (or /test/*param) then it's dynamic.
|
||||||
// If /test/: (or /test/*) then it's static.
|
// If /test/: (or /test/*) then it's static.
|
||||||
if c == paramStartCharacter {
|
if isParam, isWildcard := c == paramStartCharacter, c == wildcardParamStartCharacter; isParam || isWildcard {
|
||||||
|
n.hasDynamicChild = true
|
||||||
|
paramKeys = append(paramKeys, s[1:]) // without : or *.
|
||||||
|
if isParam {
|
||||||
n.childNamedParameter = true
|
n.childNamedParameter = true
|
||||||
s = ParamStart
|
s = ParamStart
|
||||||
} else if c == wildcardParamStartCharacter {
|
}
|
||||||
|
|
||||||
|
if isWildcard {
|
||||||
n.childWildcardParameter = true
|
n.childWildcardParameter = true
|
||||||
s = WildcardParamStart
|
s = WildcardParamStart
|
||||||
if tr.root == n {
|
if tr.root == n {
|
||||||
|
@ -150,6 +155,7 @@ func (tr *trie) insert(path string, route context.RouteReadOnly, handlers contex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !n.hasChild(s) {
|
if !n.hasChild(s) {
|
||||||
child := newTrieNode()
|
child := newTrieNode()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user