Hi all, I have been reading the documentation on route conflicts and I was wondering if someone could shed some light on why the following routes are conflicting:
; -> /:user-id/orders
; -> /public/*path
; -> /bulk/:bulk-id
Apologies if this is very basic, I’m fairly new to this. How does the matching for routes work? Is there some documentation I can read on this? Thanks for your time!@gekkostate Those three example routes can be ambiguous. If the reqeuested url is
/bulk/orders
do you want
:user-id = "bulk" on /:user-id/orders
or
:bulk-id = "orders" on /bulk/:bulk-id
? The route matching in reitit is not top-to-bottom or first match, depending on how the routing is configured: https://metosin.github.io/reitit/advanced/different_routers.html I use the :quarantine-router
for most of my projects as I often have routes such as
/item/new
and
/item/:slug
together.
Ahhhh, now I understand. Wonderful, thanks a bunch!
I think we’ll test out the quarantine router and see if it improves our situation.
putting :conflicts nil
to router options selects automatically the quarantine router
["/listing/:listing-id"
{:view :listing}
["" {:name :listing}]
["/photos" {:conflicting true
:sub :photo
:name :listing-photos}]
["/{title}/photos" {:conflicting true
:sub :photo
:name :listing-with-title-and-photos}]
["/{title}" {:conflicting true
:name :listing-with-title}]]
@gekkostate
Just had this problem and solved it like this.It selected the quarantine router automatically when I put the :conflicting true
in the routes
@ikitommi Oh that’s very interesting. We initially placed that and it indeed remove the warning however, it navigated to the wrong route! So, we decided to remove the conflicts nil and just resolve the conflict and this ended up working.
Sweeet, thanks for sharing @naomarik. I think we will try this approach in the future if there are conflicting routes that we have to deal with.
yeah in my case this is passing all unit tests
pretty damn flexible 🙂