Route precedence
See original GitHub issueAs routesMap is an object and the order of route matching depends solely on Object.keys return value. If I do something like:
const routesMap = {
HOME: '/home',
USER_NEW: '/user/new',
USER: '/user/:id',
}
There’s absolutely no guarantee that the USER_NEW route has the precedence over the USER route.
It’s possible to use regex in the matching:
const routeMaps = {
HOME: '/home',
USER_NEW: '/user/new',
USER: /user/(((?!new).)*)$/
}
But that would cause the payload to be number indexed instead of named: {0: "123" }
Is this by design? This use case would definitely be benefited by some ordering mechanism in the routes. Either an order parameter or routesMap accepting an array instead of an object would be fine I believe.
Do you see this as a valid use case?
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (12 by maintainers)
Top Results From Across the Web
Route Precedence -- How does a Router choose its preferred ...
The three attributes for Route Preference are the Route Specificity, the Administrative Distance, and the Metric. If multiple routes exist and ...
Read more >Route Preference - PacketLife.net
Prefix Length - The longest-matching route is preferred first. · Administrative Distance - In the event there are multiple routes to a ...
Read more >Sophos Firewall: Routing precedence for SSL VPN routes
According to route precedence, traffic would be traversed through Policy routing first. If the customer wants to reach a destination through SSL ...
Read more >Configure Route Selection for Routers - Cisco
Metrics are values associated with specific routes that rank them from most preferred to least preferred. The parameters used to determine the ...
Read more >How do I configure route precedence on a firewall? - SonicWall
Go to the Manage tab · Click Network | Routing · Go to the Settings tab · Enable Prioritize routes by metric within...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
good point. …though if the order is only dependent within the given injection (which is likely the case 90% of the time), then we’re right where we were before.
I probably will do the order feature at a certain point. Other things will also make it important, like URLs that are more dynamic than
:param
which use regexes.Sorry to comment this closed issue, but I think something important was pointed out by this discussion. If the implementation of injected routes is made, I think the order will be very very important. But maybe I’m wrong.
The package normalizr transform objects in two nested objects : one
entities
with an object of {id: object} objects, another with aresults
list with theid
in order. Maybe it will be usable. Just an idea.Thoughts ?