diff --git a/lib/Horde/Url.php b/lib/Horde/Url.php index b7099fd..af66173 100644 --- a/lib/Horde/Url.php +++ b/lib/Horde/Url.php @@ -265,6 +265,14 @@ public function toString($raw = false, $full = true) } if ($params = $this->parameters) { + foreach ($params as $p => &$v) { + // TODO: Investigate if it should be done for all (or some) other objects + if ($v instanceof Horde_Url) { + $v = strval($v); + } + } + unset($v); + $url .= '?' . http_build_query($params, "", $raw ? '&' : '&'); } @@ -272,7 +280,7 @@ public function toString($raw = false, $full = true) $url .= '#' . ($raw ? $this->anchor : rawurlencode($this->anchor)); } - return strval($url); + return $url; } /** @@ -297,7 +305,7 @@ public function __toString() */ public function link(array $attributes = array()) { - $url = (string)$this->setRaw(false); + $url = strval($this->setRaw(false)); $link = ' + * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 + * @category Horde + * @package Url + * @subpackage UnitTests + */ + +namespace Horde\Url; +use \PHPUnit\Framework\TestCase; +use \Horde_Url; + +class AddHordeUrlTest extends TestCase +{ + public function testAddHordeUrlToExistingUrl() + { + $url = new Horde_Url('test?foo=1&bar=2'); + $url->add('url', new Horde_Url('https://example.com/test?_t=123456&_h=Abcd123')); + $this->assertEquals('test?foo=1&bar=2&url=https%3A%2F%2Fexample.com%2Ftest%3F_t%3D123456%26_h%3DAbcd123', (string)$url); + } + +}