UnionOfRAD/lithium — Issue #204: lithium\action\Request->to('url') returns blank base path
Author: clexmond
Created: 2011-12-01 16:03:09+00:00
State: open

The lithium\action\Request->to('url') method utilizes $this->_base which calls $this->_base(). The _base() method's return uses an rtrim that includes '/' as a trim character. This results in _base() returning an empty base path instead of '/' causing to('url') to return urls like:

http://example.comfoo/bar?url=foo%2Fbar

instead of:

http://example.com/foo/bar?url=foo%2Fbar

Fix should be either the following in _base():

return rtrim(str_replace(array("/app/webroot", '/webroot'), '', $base));

or something like (this one should take into account the cases the '/' was added to rtrim in the first place for):

$base = rtrim(str_replace(array("/app/webroot", '/webroot'), '', $base));
return (empty($base)) ? '/' : $base;