vweb: fix route matching on `/` (#10001)

pull/10022/head
Miccah 2021-05-05 06:20:40 -05:00 committed by GitHub
parent 12c3f85507
commit 8b50a5a171
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -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()

View File

@ -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
}