ZF-10091: Zend_Controller_Action_Helper_Url - adds "/" in front of URL
Description
Hi,
I am fairly new to ZF and I am not quite sure this is a "real" bug... But I figured the only way to know for sure is to report about it. When building a url with Zend_Controller_Action_Helper_Url::simple() it outputs something like this: /http://sitename.com/... [with the extra / in front of it]
This is done on line 79 of the script. Now I understand that this is quite useful for relative paths... but this does not work for full URLs right ?
Maybe I am just missing the point here.. Thanks for your explanations in that case
Comments
Posted by Christoph, René Pardon (renepardon) on 2010-07-01T09:22:21.000+0000
Hi dGo,
this is probably not a bug. Can you provide some code what you've done to reproduce this problem?
Have in mind that simple() only accept these parameters: $action, $controller, $module, $params
So you can't pass a full URI to this method.
regards René
Posted by dGo (dgoosens@gmail.com) on 2010-07-01T12:50:59.000+0000
Hi Christoph,
Well, within an action, I need to build an url. I am using the following code:
$url = $this->_helper->url('send', 'mails', 'admin', array( 'mailId' => $mailId, 'senderName' => urlencode($senderDetails['senderName']), 'senderMail' => $senderDetails['senderMail'], 'adminMail' => $senderDetails['adminMail'] ));
this would output /http://mysite.com/admin/mails/…]
with the slash in front of, it which resulted in a wrong URL
Thus, I change line 79 of Zend_Controller_Action_Helper_Url from $url = '/' . ltrim($url, '/'); into $url = ltrim($url, '/');
this way, the URL is OK.
The reason I think this is a bug is beacause when looking at the function, the URL is build from the baseurl (line 66-68)
if ('' !== ($baseUrl = $this->getFrontController()->getBaseUrl())) { $url = $baseUrl . '/' . $url; }
And thus, if the $baseUrl is not empty, the url should not get prefixed with a shlash... Although... I think...
Let me know if I am not clear And thanks a lot !
dGo
Posted by dGo (dgoosens@gmail.com) on 2010-07-01T12:53:39.000+0000
URL did not come through as I wanted.. should be http: //mysite.com/admin/mails/send/mailId/[ID]/senderName/[SENDERNAME]/senderMail[SENDERMAIL]/adminMail/[ADMINMAIL]
Posted by Markus (rockaut) on 2010-10-22T10:34:49.000+0000
As this seams like an easy bug i hoped for 1.11... damn i forgot to meantion it in bug hunt days sorry.
Posted by Adam Lundrigan (adamlundrigan) on 2012-05-29T17:07:17.000+0000
Duplicate of ZF-10923