Support for Multiple Route Parameters in a Single Segment (e.g., /set-alarm-for-:hour-:minute-:amOrPm) #94
Labels
Good First Issue
Want to contribute? Just filter by this label
Type: Enhancement
Improving an existing feature
Package version
6.14
Describe the bug
AdonisJS currently lacks the ability to define multiple parameters within a single segment of the URL (e.g.,
:param1-:param2-:param3
). This feature would be highly beneficial for creating more descriptive and user-friendly URLs.Example in Laravel:
In Laravel, it is possible to define a route like this:
This allows URLs such as:
In the above example:
hour
is10
minute
is30
amOrPm
isam
Attempt in AdonisJS:
Currently, AdonisJS doesn't support this syntax. For instance, the following AdonisJS route definition:
Results in a routing error or unexpected behavior.
Feature Request:
Support for this feature would align AdonisJS with the capabilities of other frameworks like Laravel and enhance its ability to handle clean, descriptive URLs. This functionality could be implemented by allowing multiple dynamic parameters within a single segment, separated by delimiters like
-
.Benefits:
Suggested Syntax:
An example route definition in AdonisJS:
Parameters Accessible in Controller:
The parameters should be accessible like this in the handler:
Current Workaround:
To achieve a similar effect, developers must split the parameters into separate segments, such as:
This, however, results in less descriptive URLs:
Reproduction repo
No response
The text was updated successfully, but these errors were encountered: