[Catalyst] Trailing undef in uri_for()
Bill Moseley
moseley at hank.org
Tue Jun 5 14:20:33 GMT 2007
On Tue, Jun 05, 2007 at 09:18:50AM +0100, Matt S Trout wrote:
> On Mon, Jun 04, 2007 at 10:59:41PM -0700, Bill Moseley wrote:
> > In a template I was using:
> >
> > c.uri_for( 'path', arg1, arg2 );
> >
> > where arg1 and arg2 are sometimes not defined. In that case uri_for
> > generates a url with two trailing slashes.
> >
> > Is there a reason to keep that behavior or should uri_for pop any
> > undefined items off @args?
>
> I think for '' the behaviour's correct.
Hum, I can see where a single '' would be useful if you wanted to do:
$x = $c->uri_for( '/path', '' ); # include trailing slash
$x .= 'foo'; # for /path/foo
Although I'm not sure why you wouldn't just use '/foo' in that case.
But,
$c->uri_for( '/path', '','' );
would generate http://localhost/path// which doesn't seem useful.
Can you think of a case for that?
Besides:
$c->uri_form( '/path, '', '', '', 'foo' );
/path///foo
Catalyst seems to ignore the extra slashes if 'foo' is an action but
not if the action is 'path' when then the slashes effect the arguments.
Oh, and it seems in TT that:
c.uri_for( '/path', something_undef, undef ); # both undefined vars
actually calls uri_for with
( '/path', '', '' )
So, I guess what I'm asking for is to indeed remove trailing empty
strings. But, perhaps there's a valid use case for extra and trailing
slashes I'm not thinking of.
I thought Apache ignored multiple slashes as with these:
http://httpd.apache.org/docs/2.2/upgrading.html
http://httpd.apache.org/docs/2.2////upgrading.html
But different here (images and css)
http://apache.org/foundation/contributing.html
http://apache.org/foundation///contributing.html
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list