PerlDancer / Dancer2

Perl Dancer Next Generation (rewrite of Perl Dancer)
http://perldancer.org/
Other
542 stars 274 forks source link

Routes with mixed inline regexs and tokens #1642

Open veryrusty opened 2 years ago

veryrusty commented 2 years ago

When working on #1641, I planned on adding a test case for get '/(any|some)/thing/:id => sub {...}; to t/classes/Dancer2-Core-Route/match.t, which fails :(

+    [
+        [ 'get', '/(any|some)/thing/:id', sub {61} ],
+        '/some/thing/else',
+        [ { id => 'else', splat => ['some'] }, 61 ]
+    ],

The route matching code extracts the values some and else from the path; but the route regexp only has one regex with a comment. The token assignment iterates through the regex captures starting with those with comments first, assigning the rest to splat. This results in the params { id => 'some', splat => ['else'] } .. which is just wrong.

After some though, I still do not have a way to "fix" this. Creating this issue as a reminder to myself, or in hope someone else may pick it up 🤞 .