diff --git a/router.go b/router.go index 63874f37..081c6c67 100644 --- a/router.go +++ b/router.go @@ -63,6 +63,8 @@ func (r *Route) match(path, original string, params *[maxParams]string) (match b } else if r.star { if len(original) > 1 { params[0] = original[1:] + } else { + params[0] = "" } return true } diff --git a/router_test.go b/router_test.go index 9d6aa8e2..0e713de5 100644 --- a/router_test.go +++ b/router_test.go @@ -88,6 +88,16 @@ func Test_Route_Match_Star(t *testing.T) { match := route.match("", "", ¶ms) utils.AssertEqual(t, true, match) utils.AssertEqual(t, [maxParams]string{}, params) + + // with parameter + match = route.match("/favicon.ico", "/favicon.ico", ¶ms) + utils.AssertEqual(t, true, match) + utils.AssertEqual(t, [maxParams]string{"favicon.ico"}, params) + + // without parameter again + match = route.match("", "", ¶ms) + utils.AssertEqual(t, true, match) + utils.AssertEqual(t, [maxParams]string{}, params) } func Test_Route_Match_Root(t *testing.T) {