Support mixed static/dynamic route segments like `/@:username`
What is the problem this feature would solve?
Bun's built-in router supports named parameters and wildcard routes, but I need to match a parameter with a static prefix inside the same path segment.
For example:
routes: {
"/@:username": handleProfile,
"/*": handleSPA,
}/@alice should match the profile route, while everything else should fall through to the SPA catch-all for example.
This pattern is useful for user/profile URLs such as /@username without reserving an entire top-level path like /users/:username.
What is the feature you are proposing to solve the problem?
Support mixed static/dynamic route segments (prefixed named parameters), such as:
/@:username
/file-:id
/:name.jsonThe more specific route should take precedence over a general /* catch-all.
What alternatives have you considered?
Currently I'm handling it through a catch-all route and do the logic manually and if it doesn't match I internally fetch() by parsing URL.pathname. It works, adds a bit of overhead (fetch) and a direct implementation would be much cleaner.
Source: oven-sh/bun