-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow users to have an additional regex node #317
Comments
I have some doubts about that #314 (comment). I'm not sure that it's possible. |
This is doable and it would allow us to cover more cases. |
How would you resolve cases like this #314 (comment)? |
I think it is a matter of strictness and execution order (from left to right) over priority Taking the examples
I would expect
|
@Eomm What do you think about case like that? Can we say that the node with a static ending has higher priority than a regexp one?
|
I would say: yes, but - may it be a user error? |
That is a part of the question. If we think that those routes have the same priority, then we should throw an error. It's basically a question of param nodes' static endings. In some cases, we want to allow users to have two similar nodes with different static endings in the param. This is working now. We don't need to prioritize them, because it's impossible to match them both:
The idea of this issue is to add support for routes like that. In this case, we can tell that second route has higher priority than the first one:
The question is: should we go further and allow users to have:
But make sure that we don't care about regexp value. So this would also work if we allow it to work:
|
Can we draw a line like more specific chunk should match first at the same level. For example, Or even |
The name of the We have three different node types: static, parametric, and wildcard. Static node always has the highest priority, wildcard node - the lowest. Everything between them is a parametric node. Parametric node always starts with a
I might agree with that. It's a part of my question.
I disagree with that. Make sure that all regexp in your example can be different:
I don't see why the first node should always have higher priority. Feel free to change my mind.
I think completely opposite. The first route in your example is a regexp node from the logical point of view. It can be unclear, but we can treat it only as one big regexp like that Example to show another point of view:
Don't forget that we can say that comparing nodes like that is incorrect and keep thowing an error like we always did. |
Since https://github.com/delvedor/find-my-way#match-order Basically, it would be the reverse order of 4. and 5.
I don't mind if it continue to throw at this point. And update the behavior when we have more consensus. |
find-my-way has a caveat: it can't have two different routes which differ only for their parameters. What we can allow users to have is a regular parametrical node and a regexp node (or multi-parametrical node, which is also a regexp node), in case there is only one regex node. In this case, we know that the regex node has higher priority than the regular one.
Example:
/foo/:param1
/foo/:param2.png
@mcollina @Eomm @Uzlopak @RafaelGSS @climba03003 WDYT?
The text was updated successfully, but these errors were encountered: