[Catalyst] Regex -- optional index.html

Bill Moseley moseley at hank.org
Fri Mar 2 00:13:05 GMT 2007


On Fri, Mar 02, 2007 at 12:08:42AM +0100, Boris ?erani? wrote:
> >    Regex('^training/webcasts/webcast_data/(\d+)/?(index.html)?$')
> >
> >        matches:
> >            ../186/index.html   : yes
> >            ../186/foo.html     : yes
> >            ../186/             : yes
> >            ../186              : yes
> >
> >
> (snip)
> 
> Actually, this one works for me quite well - it should work fine for
> following scenarios:
> 
> .../186
> .../186/
> .../186/index.html
> 
> In any other case, it will fail, as you can see:

Yes, when tested in Perl it works that way, but in Catalyst in other
cases it still matches.  That's the problem.

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*

So that's why it's matchine when I don't want it to match.


-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list