Problem to Solve
Given two routes:
/host/**
/*/assets/something
The path /host/assets/something will match route 1, since we always match literal segments first (host match host and assets/something match **).
But what if you want it to match 2?
Two natural work-arounds exists. Either
- Change 1. to
/host/app/** (will solve the issue by backtracking, since assets doesn't match app), or
- Ensure the handler of 2 is also registered at
/host/assets/something (will solve the issue, since literal match always wins over dynamic).
But both workarounds require you to change your registered routes. The first (1) requires clients to use a less pretty url like https://foo.domain.com/app (as opposed to just https://foo.domain.com) and the second (2) require setting up two routes for the same handler (duplication and not obvious).
Short of the work-arounds I don't currently see an elegant way to expose reversing the match order for some dynamic routes like /*/assets/something (so * match before host), since this is definitely not something you want in general. But the use-case is real, so tracking this.
Currently matching is NOT dependent on registration order, which is something I'm very loathe to give up, as it composes much better in large code bases, where route registration is spread out across multiple modules.
Proposal
Not sure yet
Use Case
Vanity urls for SPA combined with first-segment dynamic routes. This came up on scloud when they try to register two flutter apps on the root of different virtual hosts, while also using their dynamic config trick.
Maybe others..
Alternatives
Work arounds given above
Additional context
No response
How experienced are you with this library?
Expert - Experienced and comfortable with using this library in complex projects
Are you interested in working on a PR for this?
Problem to Solve
Given two routes:
/host/**/*/assets/somethingThe path
/host/assets/somethingwill match route 1, since we always match literal segments first (hostmatchhostandassets/somethingmatch**).But what if you want it to match 2?
Two natural work-arounds exists. Either
/host/app/**(will solve the issue by backtracking, sinceassetsdoesn't matchapp), or/host/assets/something(will solve the issue, since literal match always wins over dynamic).But both workarounds require you to change your registered routes. The first (1) requires clients to use a less pretty url like
https://foo.domain.com/app(as opposed to justhttps://foo.domain.com) and the second (2) require setting up two routes for the same handler (duplication and not obvious).Short of the work-arounds I don't currently see an elegant way to expose reversing the match order for some dynamic routes like
/*/assets/something(so*match beforehost), since this is definitely not something you want in general. But the use-case is real, so tracking this.Currently matching is NOT dependent on registration order, which is something I'm very loathe to give up, as it composes much better in large code bases, where route registration is spread out across multiple modules.
Proposal
Not sure yet
Use Case
Vanity urls for SPA combined with first-segment dynamic routes. This came up on scloud when they try to register two flutter apps on the root of different virtual hosts, while also using their dynamic config trick.
Maybe others..
Alternatives
Work arounds given above
Additional context
No response
How experienced are you with this library?
Expert - Experienced and comfortable with using this library in complex projects
Are you interested in working on a PR for this?