Edit report at https://pear.php.net/bugs/bug.php?id=19176&edit=1
ID: 19176
Updated by: mkauffman@rightnow.com
Reported By: mkauffman at rightnow dot com
-Summary: resolve() does not merge the path if the base url is
empty
+Summary: resolve() does not merge the path if the base path is
empty
Status: Open
Type: Bug
Package: Net_URL2
Operating System: Linux
Package Version: 2.0.0
PHP Version: 5.2.12
Roadmap Versions:
New Comment:
-Summary: resolve() does not merge the path if the base url is
empty
+Summary: resolve() does not merge the path if the base path is
empty
Fixed the summary to reference base path
Previous Comments:
------------------------------------------------------------------------
[2011-12-31 02:07:54] wellnamed
Description:
------------
If you define a Net_URL2 instance that looks like "http://www.foo.com"
and then output $foo->resolve('bar.html')->getUrl()
The resulting url is "http://www.foo.com/"
It appears to me that the issue is at line 729 in URL2.php. The line
$target->_path .= $reference->_path;
should be outside of the else statement so that it appends the reference
path in both cases. This seems to fix at least this case, although I
confess I haven't done enough testing and am not familiar enough with
this code to be sure that it's entirely correct.
Test script:
---------------
$foo = new new Net_URL2("http://www.foo.com");
$test = $foo->resolve('test.html')->getURL();
print $test;
Expected result:
----------------
http://www.foo.com/test.html
Actual result:
--------------
http://www.foo.com/
------------------------------------------------------------------------