I am working on a Coldbox application and keep running into what I believe is a conflict in my routes, however it could also be my lack of understanding around the matter.
Consider the following routes, both using regex to limit the number of possible values:
route (
pattern="/product/:product-regex:(productA|productB)",
target=“product.index”,
name=“Product”
).end();
route (
pattern="/product/:product-regex:(productA|productB)/environment/:environment-regex:(prod|staging|qa)/client/:client",
target=“client.index”,
name=“Client”
).end();
With these routes in mind, when I hit the following URL: http://127.0.0.1:64493/product/productA/environment/staging/client/clientABC, I land on the appropriate “client” handler. If I enter some bogus data into the “environment” section of the route (ie: not “prod”, “staging”, or “qa”), I land on the “product” handler, which, I think, is incorrect (and definitely not the desired result.
Now, if I remove the top route (product.index handler), reinit the app, I can plug bogus data into both product and/or environment sections of the route and both will trigger the invalidEventHandler. What appears to be happening is that the top route is somehow conflicting with the bottom route, so if the “product” section of the route matches, even if the regex for the “environment” fails, it falls back to the first route.
Is this by design, a design flaw on my end, or something else? Any help or insight anybody can provide is greatly appreciated.
- Tony