fix the same name controller for UrlFor

This commit is contained in:
astaxie 2014-09-23 00:26:07 +08:00
parent 7e060e6e5c
commit f267ee8a12
1 changed files with 3 additions and 2 deletions

View File

@ -415,7 +415,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
}
}
}
controllName := strings.Join(paths[:len(paths)-1], ".")
controllName := strings.Join(paths[:len(paths)-1], "/")
methodName := paths[len(paths)-1]
for _, t := range p.routers {
ok, url := p.geturl(t, "/", controllName, methodName, params)
@ -443,7 +443,8 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin
}
for _, l := range t.leaves {
if c, ok := l.runObject.(*controllerInfo); ok {
if c.routerType == routerTypeBeego && c.controllerType.Name() == controllName {
if c.routerType == routerTypeBeego &&
strings.HasSuffix(path.Join(c.controllerType.PkgPath(), c.controllerType.Name()), controllName) {
find := false
if _, ok := HTTPMETHOD[strings.ToUpper(methodName)]; ok {
if len(c.methods) == 0 {