[Catalyst] Regex -- optional index.html

Michael Reece mreece at vinq.com
Fri Mar 2 19:43:17 GMT 2007


i don't think it's a bug.


Catalyst::Manual::Intro also says:

   You can pass variable arguments as part of the URL path, separated  
with forward slashes (/). If the action is a Regex or LocalRegex, the  
'$' anchor must be used. For example, suppose you want to handle /foo/ 
$bar/$baz, where $bar and $baz may vary:

     sub foo : Regex('^foo$') { my ($self, $context, $bar, $baz) = @_; }
[..snip..]

   If a Regex or LocalRegex action doesn't use the '$' anchor, the  
action will still match a URL containing arguments, however the  
arguments won't be available via @_.


have you tried adding :Args(0) to the action?


On Mar 2, 2007, at 9:59 AM, Bill Moseley wrote:

> On Thu, Mar 01, 2007 at 04:13:05PM -0800, Bill Moseley wrote:
>> Seems that Catalyst first tries to match the full path, then tries to
>> match a reduced path.  Adding a bit of debugging to Regex.pm's  
>> match()
>> method:
>>
>>     Request = /training/webcasts/webcast_data/162/foo.html
>>
>>     Checking [training/webcasts/webcast_data/162/foo.html]
>>     Checking [training/webcasts/webcast_data/162]
>>     *MATCHED*
>
> Ok, so is that a bug?  Or am I not understanding the docs?
>
>     # Regex
>
>         sub bar : Regex('^item(\d+)/order(\d+)$') { }
>
>     Matches any URL that matches the pattern in the action key, e.g.
>     http://localhost:3000/item23/order42. The '' around the regexp is
>     optional, but perltidy likes it. :)
>
> So it seems that would also match:
>
>     http://localhost:3000/item23/order42/something.else
>
> but the "$" would indicate to me that it much only match the shorter
> string.
>
>
> -- 
> Bill Moseley
> moseley at hank.org
>
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/ 
> catalyst at lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/

---
michael reece :: software engineer :: mreece at vinq.com





More information about the Catalyst mailing list