diff --git a/lib/get_navigation/src/routes/parse_route.dart b/lib/get_navigation/src/routes/parse_route.dart index 7c28103a..263f6557 100644 --- a/lib/get_navigation/src/routes/parse_route.dart +++ b/lib/get_navigation/src/routes/parse_route.dart @@ -267,17 +267,17 @@ class ParseRouteTree { Map _parseParams(String path, PathDecoded routePath) { final params = {}; var idx = path.indexOf('?'); + final uri = Uri.tryParse(path); + if (uri == null) return params; if (idx > -1) { - path = path.substring(0, idx); - final uri = Uri.tryParse(path); - if (uri != null) { - params.addAll(uri.queryParameters); - } + params.addAll(uri.queryParameters); + } + var paramsMatch = routePath.regex.firstMatch(uri.path); + if (paramsMatch == null) { + return params; } - var paramsMatch = routePath.regex.firstMatch(path); - for (var i = 0; i < routePath.keys.length; i++) { - var param = Uri.decodeQueryComponent(paramsMatch![i + 1]!); + var param = Uri.decodeQueryComponent(paramsMatch[i + 1]!); params[routePath.keys[i]!] = param; } return params; diff --git a/test/navigation/parse_route_test.dart b/test/navigation/parse_route_test.dart index 770435c1..a046bf3e 100644 --- a/test/navigation/parse_route_test.dart +++ b/test/navigation/parse_route_test.dart @@ -135,7 +135,8 @@ void main() { GetPage(page: () => Container(), name: '/first/:name'), GetPage(page: () => Container(), name: '/second/:id'), GetPage(page: () => Container(), name: '/third'), - GetPage(page: () => Container(), name: '/last/:id/:name/profile') + GetPage(page: () => Container(), name: '/last/:id/:name/profile'), + GetPage(page: () => Container(), name: '/first/second/:token') ], )); @@ -168,6 +169,12 @@ void main() { expect(Get.parameters['id'], '1234'); expect(Get.parameters['name'], 'ana'); expect(Get.parameters['job'], 'dev'); + + Get.toNamed( + 'https://www.example.com/first/second/fa9662f4-ec3f-11ee-a806-169a3915b383', + ); + await tester.pumpAndSettle(); + expect(Get.parameters['token'], 'fa9662f4-ec3f-11ee-a806-169a3915b383'); }, );