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
08b3e419
Commit
08b3e419
authored
Sep 04, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into develop
parents
d06e0247
4f4f7ce2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
tree.go
tree.go
+11
-4
tree_test.go
tree_test.go
+3
-0
No files found.
tree.go
View file @
08b3e419
...
...
@@ -237,12 +237,18 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string,
regexpStr
=
"/"
+
regexpStr
}
}
else
if
reg
!=
""
{
for
_
,
w
:=
range
params
{
if
w
==
"."
||
w
==
":"
{
continue
if
seg
==
"*.*"
{
regexpStr
=
"/([^.]+).(.+)"
}
else
{
for
_
,
w
:=
range
params
{
if
w
==
"."
||
w
==
":"
{
continue
}
regexpStr
=
"/([^/]+)"
+
regexpStr
}
regexpStr
=
"/([^/]+)"
+
regexpStr
}
}
t
.
wildcard
.
addseg
(
segments
[
1
:
],
route
,
append
(
wildcards
,
params
...
),
reg
+
regexpStr
)
}
else
{
...
...
@@ -396,6 +402,7 @@ func (leaf *leafInfo) match(wildcardValues []string) (ok bool, params map[string
}
return
true
,
params
}
if
!
leaf
.
regexps
.
MatchString
(
path
.
Join
(
wildcardValues
...
))
{
return
false
,
nil
}
...
...
tree_test.go
View file @
08b3e419
...
...
@@ -42,6 +42,9 @@ func init() {
routers
=
append
(
routers
,
testinfo
{
"/*.*"
,
"/nice/api.json"
,
map
[
string
]
string
{
":path"
:
"nice/api"
,
":ext"
:
"json"
}})
routers
=
append
(
routers
,
testinfo
{
"/:name/*.*"
,
"/nice/api.json"
,
map
[
string
]
string
{
":name"
:
"nice"
,
":path"
:
"api"
,
":ext"
:
"json"
}})
routers
=
append
(
routers
,
testinfo
{
"/:name/test/*.*"
,
"/nice/test/api.json"
,
map
[
string
]
string
{
":name"
:
"nice"
,
":path"
:
"api"
,
":ext"
:
"json"
}})
routers
=
append
(
routers
,
testinfo
{
"/dl/:width:int/:height:int/*.*"
,
"/dl/48/48/05ac66d9bda00a3acf948c43e306fc9a.jpg"
,
map
[
string
]
string
{
":width"
:
"48"
,
":height"
:
"48"
,
":ext"
:
"jpg"
,
":path"
:
"05ac66d9bda00a3acf948c43e306fc9a"
}})
routers
=
append
(
routers
,
testinfo
{
"/v1/shop/:id:int"
,
"/v1/shop/123"
,
map
[
string
]
string
{
":id"
:
"123"
}})
routers
=
append
(
routers
,
testinfo
{
"/:year:int/:month:int/:id/:endid"
,
"/1111/111/aaa/aaa"
,
map
[
string
]
string
{
":year"
:
"1111"
,
":month"
:
"111"
,
":id"
:
"aaa"
,
":endid"
:
"aaa"
}})
routers
=
append
(
routers
,
testinfo
{
"/v1/shop/:id/:name"
,
"/v1/shop/123/nike"
,
map
[
string
]
string
{
":id"
:
"123"
,
":name"
:
"nike"
}})
...
...
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