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
67fbafb3
Commit
67fbafb3
authored
Feb 26, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1680 from ysqi/fix-router-error
fix #1595
parents
6eaa5537
94110635
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
tree.go
tree.go
+4
-5
tree_test.go
tree_test.go
+12
-0
No files found.
tree.go
View file @
67fbafb3
...
...
@@ -265,15 +265,14 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string,
}
t
.
wildcard
.
addseg
(
segments
[
1
:
],
route
,
append
(
wildcards
,
params
...
),
reg
+
regexpStr
)
}
else
{
var
ok
bool
var
subTree
*
Tree
for
_
,
sub
Tree
=
range
t
.
fixrouters
{
if
t
.
prefix
==
seg
{
ok
=
true
for
_
,
sub
:
=
range
t
.
fixrouters
{
if
sub
.
prefix
==
seg
{
subTree
=
sub
break
}
}
if
!
ok
{
if
subTree
==
nil
{
subTree
=
NewTree
()
subTree
.
prefix
=
seg
t
.
fixrouters
=
append
(
t
.
fixrouters
,
subTree
)
...
...
tree_test.go
View file @
67fbafb3
...
...
@@ -221,6 +221,18 @@ func TestAddTree4(t *testing.T) {
}
}
// Test for issue #1595
func
TestAddTree5
(
t
*
testing
.
T
)
{
tr
:=
NewTree
()
tr
.
AddRouter
(
"/v1/shop/:id"
,
"shopdetail"
)
tr
.
AddRouter
(
"/v1/shop/"
,
"shophome"
)
ctx
:=
context
.
NewContext
()
obj
:=
tr
.
Match
(
"/v1/shop/"
,
ctx
)
if
obj
==
nil
||
obj
.
(
string
)
!=
"shophome"
{
t
.
Fatal
(
"url /v1/shop/ need match router /v1/shop/ "
)
}
}
func
TestSplitPath
(
t
*
testing
.
T
)
{
a
:=
splitPath
(
""
)
if
len
(
a
)
!=
0
{
...
...
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