From fd9508ca394dd5831556cb7eb5e79f2c2f12c29f Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Thu, 17 Nov 2016 18:42:00 -0800 Subject: [PATCH] param alias, context#param Signed-off-by: Vishal Rana --- context.go | 2 +- router.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/context.go b/context.go index da035a4c..71bc3e4f 100644 --- a/context.go +++ b/context.go @@ -237,7 +237,7 @@ func (c *context) SetPath(p string) { func (c *context) Param(name string) string { for i, n := range c.pnames { - if i < len(c.pnames) { + if i < len(c.pvalues) { if n == name { return c.pvalues[i] } diff --git a/router.go b/router.go index b53edb5a..b06bb1d7 100644 --- a/router.go +++ b/router.go @@ -177,8 +177,8 @@ func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string } for i, n := range pnames { // Param name aliases - if !strings.Contains(n, pnames[i]) { - cn.pnames[i] += "," + pnames[i] + if i < len(cn.pnames) && !strings.Contains(cn.pnames[i], n) { + cn.pnames[i] += "," + n } } }