Comments (2)
@rsegecin not sure if you're understood that correctly. The example above shows two different routes, so two different pages using the same query parameter name. That should be fairly common. The routes are NOT instantiated at the same time, it just happens to be, that the value sent in the query parameter contains something (an url) that effectively as a "magic string" at the end. There is no reason, the router should care about the string content of the query parameter value. It should just be a string and arrive there, whatever it's contents may be. The router should encode whatever needs to be encoded to create a valid URL. By the way, it does that by using the Uri
class internally. But after that, it decodes the URL with this strange function at a point where decoding does not even make sense nor is needed (I believe).
I did a bit more testing and i'am pretty sure the use of decodeFull
in UrlState
is simply incorrect.
Here is another case that may explain the issue:
/// the constructor of SomePage, registered as /some-route
SomePage({
@QueryParam('myQueryParam') this.myQueryParam,
});
// now somebody calls
AutoRouter.of(context).replace(SomeRoute(
// the following query parameter value may seem silly but there is no reason this should not be possible
// it's just a string that needs encoding
myQueryParam: "?=:http://&"
));
// i did not test this case explicitly but i am pretty sure the resulting url is will be something like that:
// /some-route?myQueryParam=?=:http://&
// but it should actually be:
// /some-route?myQueryParam=%3F%3D%3Ahttp%3A%2F%2F%26
// the reason is, that the parameters need to be encoded but that is not the case
// because Uri.decodeFull simply decodes everything, discarding any association
// of the query parameter and it's value.
Also see the documentation of Uri.decodeFull
(https://api.flutter.dev/flutter/dart-core/Uri/decodeFull.html), it notes:
Note that decoding a full URI might change its meaning as some of the decoded characters could be reserved characters. In most cases, an encoded URI should be parsed into components using Uri.parse before decoding the separate components.
from auto_route_library.
I've never encountered a web framework or library that accepts query parameters named in the manner you're suggesting, such as having multiple parameters with the same name like "redirectTo". This practice may lead to confusion and unexpected behavior during URL parsing.
A more conventional approach would be to implement redirection logic using guards. After processing user login data, you can store relevant information in cookies. Then, utilize guards to analyze the cookie data and redirect users accordingly. For scenarios like onboarding processes where multiple redirection paths may be necessary, employing multiple guards can help manage the redirection flow effectively.
from auto_route_library.
Related Issues (20)
- Missing Back Button after refresh on web HOT 9
- Issue with Global Constants as Default Values in Route Generation HOT 1
- Unable to access ` tabsRouter` from Tab's child to navigate to desired index
- inconsistent back button in app bar when using child routes HOT 1
- AutoRouterDelegate.declarative is deprecated - use guards instead - no docs? HOT 8
- Explicit Type Casting for Route Assignments HOT 1
- context.router.pushNamed is not working HOT 7
- Issue with screen going blank after navigating back from nested routes with wrappers in version 8.0.0 HOT 2
- Can not swipe back on iOS when using nested navigation HOT 10
- Question: Access BuildContext from within AutoRouteGuard HOT 1
- Redirect on arg parsing fail HOT 5
- Back button on Android closes App on Sub route
- Implement Persist Navigation State Feature
- Back navigation blank issue still persists in 8.1.1 HOT 1
- removeWhere removes the wrong route HOT 1
- PopScope not working on web browser back button HOT 1
- How to add new Nested Navigation Tab dynamically?
- Deeplink getting called multiple times HOT 12
- Child pages are not rendered after exiting a nested initial page with the back gesture and launching from the Android launcher. HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auto_route_library.