From 35e340b9375bb76fa64d912d488fef082f132351 Mon Sep 17 00:00:00 2001 From: Henrique Bejgel Date: Mon, 18 Jan 2016 21:35:14 -0200 Subject: [PATCH] Checks if index is greater than the length of the wildcards. #1580 --- tree.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tree.go b/tree.go index 72ef3dda..ffd444d4 100644 --- a/tree.go +++ b/tree.go @@ -420,7 +420,11 @@ func (leaf *leafInfo) match(wildcardValues []string, ctx *context.Context) (ok b if len(strs) == 2 { ctx.Input.SetParam(":ext", strs[1]) } - ctx.Input.SetParam(":path", path.Join(path.Join(wildcardValues[index:len(wildcardValues)-1]...), strs[0])) + if index > (len(wildcardValues) - 1) { + ctx.Input.SetParam(":path", "") + } else { + ctx.Input.SetParam(":path", path.Join(path.Join(wildcardValues[index:len(wildcardValues)-1]...), strs[0])) + } return true } // match :id