abstract-state-router
abstract-state-router copied to clipboard
Ignore parameters that are not used by any state
This is one of my diversions from ui-router behavior that I regret.
Right now, you can pass whatever parameters into stateRouter.go or stateRouter.makePath and they will get put into the url and show up on the parameters object, even if no state depends on them.
I think that if you attempt to create a route, or if you try to navigate to a route, and you use any parameters that are not used by any of the states at the route you're going to, then those parameters should just be dropped and shouldn't show up in the url.
This could be accomplished with only a feature bump if a new option was added to stateRouter initialization, something like allowParametersNotUsedByAnyState or whatever. It could default to true (the current behavior).
Eventually, we could log a deprecation warning when that value was true, and eventually eventually we could flip the default to false.
Any thoughts?
The existing behavior does have the side effect of your state's state being maintained if the user navigates away from it and back. 🤷🏼♂️
But that's the only thing I could see someone currently relying on, as the parameters aren't actually passed into activate/resolve if they're not defined in the state's parameter list.
A more backwards-compatible way to do this would also be to leave the unused parameters in the URL, but not pass the values to the resolve/activate functions.