Skip to content

Commit

Permalink
Merge pull request #3067 from korutx/fix-parse-route
Browse files Browse the repository at this point in the history
Enhance Getx Route Parsing for HTTP/S App Links Compatibility
  • Loading branch information
jonataslaw authored Mar 29, 2024
2 parents 2d54f9a + a99091d commit 414785e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lib/get_navigation/src/routes/parse_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ class ParseRouteTree {
Map<String, String> _parseParams(String path, PathDecoded routePath) {
final params = <String, String>{};
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;
Expand Down
9 changes: 8 additions & 1 deletion test/navigation/parse_route_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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')
],
));

Expand Down Expand Up @@ -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');
},
);

Expand Down

2 comments on commit 414785e

@ettaegbe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to override my pubspec to use this commit but I keep getting the following error

Git error. Command: git fetch
stdout:
stderr: error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
error: 849 bytes of body are still expected
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
warning: unable to unlink '(NULL)': Invalid argument

This is the config I'm using

  get:
    git:
      url: https://github.com/jonataslaw/getx
      ref: 414785e7bdc73d21772da7fd199b4e4df25c855f

What is blocking?

@ettaegbe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonataslaw please can you publish this update? It's really important

Please sign in to comment.