Fixes error when you have multiple parameters in a url
This PR fixes the error in #1170 allowing you to have urls with multiple parameters
Showing
1 changed file
with
6 additions
and
1 deletions
@@ -97,8 +97,13 @@ class ParseRouteTree { | @@ -97,8 +97,13 @@ class ParseRouteTree { | ||
97 | 97 | ||
98 | Map<String, String> _parseParams(String path, PathDecoded routePath) { | 98 | Map<String, String> _parseParams(String path, PathDecoded routePath) { |
99 | final params = <String, String>{}; | 99 | final params = <String, String>{}; |
100 | + var idx = path.indexOf('?'); | ||
101 | + if (idx > -1) { | ||
102 | + path = path.substring(0, idx); | ||
103 | + final uri = Uri.tryParse(path); | ||
104 | + params.addAll(uri.queryParameters); | ||
105 | + } | ||
100 | Match paramsMatch = routePath.regex.firstMatch(path); | 106 | Match paramsMatch = routePath.regex.firstMatch(path); |
101 | - | ||
102 | for (var i = 0; i < routePath.keys.length; i++) { | 107 | for (var i = 0; i < routePath.keys.length; i++) { |
103 | var param = Uri.decodeQueryComponent(paramsMatch[i + 1]); | 108 | var param = Uri.decodeQueryComponent(paramsMatch[i + 1]); |
104 | params[routePath.keys[i]] = param; | 109 | params[routePath.keys[i]] = param; |
-
Please register or login to post a comment