f267ee8a by astaxie

fix the same name controller for UrlFor

1 parent 7e060e6e
...@@ -415,7 +415,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { ...@@ -415,7 +415,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
415 } 415 }
416 } 416 }
417 } 417 }
418 controllName := strings.Join(paths[:len(paths)-1], ".") 418 controllName := strings.Join(paths[:len(paths)-1], "/")
419 methodName := paths[len(paths)-1] 419 methodName := paths[len(paths)-1]
420 for _, t := range p.routers { 420 for _, t := range p.routers {
421 ok, url := p.geturl(t, "/", controllName, methodName, params) 421 ok, url := p.geturl(t, "/", controllName, methodName, params)
...@@ -443,7 +443,8 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin ...@@ -443,7 +443,8 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin
443 } 443 }
444 for _, l := range t.leaves { 444 for _, l := range t.leaves {
445 if c, ok := l.runObject.(*controllerInfo); ok { 445 if c, ok := l.runObject.(*controllerInfo); ok {
446 if c.routerType == routerTypeBeego && c.controllerType.Name() == controllName { 446 if c.routerType == routerTypeBeego &&
447 strings.HasSuffix(path.Join(c.controllerType.PkgPath(), c.controllerType.Name()), controllName) {
447 find := false 448 find := false
448 if _, ok := HTTPMETHOD[strings.ToUpper(methodName)]; ok { 449 if _, ok := HTTPMETHOD[strings.ToUpper(methodName)]; ok {
449 if len(c.methods) == 0 { 450 if len(c.methods) == 0 {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!