Flutterando / modular

A smart project structure
https://pub.dev/packages/flutter_modular
Other
1.31k stars 254 forks source link

Fix the logical flux control on WebUrlService Class - FLutterWeb #963

Open rfmeloneto opened 4 months ago

rfmeloneto commented 4 months ago

Description

This bugs happens on FlutterWeb and when the initalRoute is "/"

The bug happens on FlutterWeb when you click on a link that contains a path after '#' or paste it on browser and the link ends with "/" and your initialRoute is "/" then the window reloads and redirects you to the home screen.

The reason for this bug is because on the WebUrlService, the logical check for UrlStrategy, first checks if the href ends with initialRoute, and because the link ends with "/" and the initalRoute is "/" the condition is satisfied and the user is redirected to the home screen and not to the desired destination. To fix that, this PR only inverts the logic of the UrlStrategy check. The logic on this PR first checks if the href contains '#' than if it ends with initialRoute.

Checklist

Breaking Change

Related Issues

This PR can solve the bug related on issue https://github.com/Flutterando/modular/issues/834

And i think it can solve the issue https://github.com/Flutterando/modular/issues/956

GustavoFigueira commented 2 months ago

Someone to approve this PR please? This fixes the broken Modular.setInitialRoute on Flutter's last version (3.24.1) with flutter_modular last version (6.3.4).