diff --git a/vlib/vweb/route_test.v b/vlib/vweb/route_test.v index 7ca375cf7c..2025fa3baa 100644 --- a/vlib/vweb/route_test.v +++ b/vlib/vweb/route_test.v @@ -55,6 +55,10 @@ fn test_route_no_match() { url: '/a/b/c/d' route: '/a/b/c' }, + RoutePair{ + url: '/a/b/c' + route: '/' + }, ] for test in tests { test.test_no_match() diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 57bea00d36..2a2242a84d 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -443,7 +443,7 @@ fn route_matches(url_words []string, route_words []string) ?[]string { } // The last route can end with ... indicating an array - if !route_words[route_words.len - 1].ends_with('...') { + if route_words.len == 0 || !route_words[route_words.len - 1].ends_with('...') { return none }