Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
571f9b4b
Commit
571f9b4b
authored
Mar 11, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1780 from goodloop/develop
fix static pattern match for leaf
parents
1f0a65f0
90e7d252
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
tree.go
tree.go
+1
-1
tree_test.go
tree_test.go
+15
-0
No files found.
tree.go
View file @
571f9b4b
...
...
@@ -389,7 +389,7 @@ type leafInfo struct {
func
(
leaf
*
leafInfo
)
match
(
wildcardValues
[]
string
,
ctx
*
context
.
Context
)
(
ok
bool
)
{
//fmt.Println("Leaf:", wildcardValues, leaf.wildcards, leaf.regexps)
if
leaf
.
regexps
==
nil
{
if
len
(
wildcardValues
)
==
0
{
// static path
if
len
(
wildcardValues
)
==
0
&&
len
(
leaf
.
wildcards
)
==
0
{
// static path
return
true
}
// match *
...
...
tree_test.go
View file @
571f9b4b
...
...
@@ -97,6 +97,21 @@ func TestTreeRouters(t *testing.T) {
}
}
func
TestStaticPath
(
t
*
testing
.
T
)
{
tr
:=
NewTree
()
tr
.
AddRouter
(
"/topic/:id"
,
"wildcard"
)
tr
.
AddRouter
(
"/topic"
,
"static"
)
ctx
:=
context
.
NewContext
()
obj
:=
tr
.
Match
(
"/topic"
,
ctx
)
if
obj
==
nil
||
obj
.
(
string
)
!=
"static"
{
t
.
Fatal
(
"/topic is a static route"
)
}
obj
=
tr
.
Match
(
"/topic/1"
,
ctx
)
if
obj
==
nil
||
obj
.
(
string
)
!=
"wildcard"
{
t
.
Fatal
(
"/topic/1 is a wildcard route"
)
}
}
func
TestAddTree
(
t
*
testing
.
T
)
{
tr
:=
NewTree
()
tr
.
AddRouter
(
"/shop/:id/account"
,
"astaxie"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment