From f267ee8a126f56ac824023e2bdd3fc8b3ff2d338 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 23 Sep 2014 00:26:07 +0800 Subject: [PATCH] fix the same name controller for UrlFor --- router.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/router.go b/router.go index 7c52b9fc..18be04d3 100644 --- a/router.go +++ b/router.go @@ -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 {