From c38b7ad69d738281e6569e447e8d3e634097d9a4 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 9 Oct 2023 10:29:18 -0600 Subject: fix for Router.Mount() --- router.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'router.go') diff --git a/router.go b/router.go index 7cf3142..dfa936e 100644 --- a/router.go +++ b/router.go @@ -86,9 +86,14 @@ func (r *Router) Mount(prefix string, subrouter *Router) { prefix = strings.TrimSuffix(prefix, "/") for _, subroute := range subrouter.tree.Routes() { - r.Route(path.Join(prefix, subroute.Pattern), subroute.Value) - if subroute.Pattern == "/" { + fullroute := path.Join(prefix, subroute.Pattern) + if strings.HasSuffix(subroute.Pattern, "/") { + fullroute = fullroute + "/" + } + r.Route(fullroute, subroute.Value) + if subroute.Pattern == "/" || subroute.Pattern == "" { r.Route(prefix, subroute.Value) + r.Route(prefix+"/", subroute.Value) } } } -- cgit v1.2.3