question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

As 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:closed
  • Created 6 years ago
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
faceyspaceycommented, Aug 4, 2017

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.

1reaction
GuillaumeCiscocommented, Aug 4, 2017

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 a results list with the id in order. Maybe it will be usable. Just an idea.

Thoughts ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found