mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 05:01:28 +00:00
fix router's bug
This commit is contained in:
parent
2f02653b7d
commit
465ed4b72f
11
router.go
11
router.go
@ -51,12 +51,12 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface) {
|
|||||||
//match /post/:username:word ([\w]+)
|
//match /post/:username:word ([\w]+)
|
||||||
} else if lindex := strings.LastIndex(part, ":"); lindex != 0 {
|
} else if lindex := strings.LastIndex(part, ":"); lindex != 0 {
|
||||||
switch part[lindex:] {
|
switch part[lindex:] {
|
||||||
case "int":
|
case ":int":
|
||||||
expr = "([0-9]+)"
|
expr = "([0-9]+)"
|
||||||
part = part[:index]
|
part = part[:lindex]
|
||||||
case "word":
|
case ":word":
|
||||||
expr = `([\w]+)`
|
expr = `([\w]+)`
|
||||||
part = part[:index]
|
part = part[:lindex]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
params[j] = part
|
params[j] = part
|
||||||
@ -67,10 +67,9 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface) {
|
|||||||
expr := "(.+)"
|
expr := "(.+)"
|
||||||
if part == "*.*" {
|
if part == "*.*" {
|
||||||
params[j] = ":path"
|
params[j] = ":path"
|
||||||
parts[j] = "([^.]+)."
|
parts[i] = "([^.]+).([^.]+)"
|
||||||
j++
|
j++
|
||||||
params[j] = ":ext"
|
params[j] = ":ext"
|
||||||
parts[j] = "([^.]+)"
|
|
||||||
j++
|
j++
|
||||||
} else {
|
} else {
|
||||||
params[j] = ":splat"
|
params[j] = ":splat"
|
||||||
|
Loading…
Reference in New Issue
Block a user