我正在尝试使用simple_html_dom和Net_URL2将相对路径规范化为完整网址,像src="/my_path"
这样的路径通过像this这样的路径进行规范化,但这样的路径:src="my_path"
不是!如何规范化这些路径?
示例:
$uri = new Net_URL2("http://test.com");
print $uri->resolve('/my_path') . "\n"; // works
print $uri->resolve('my_path') . "\n"; // doesn't work!
答案 0 :(得分:1)
您所描述的是Net_URL2中的已知错误:http://pear.php.net/bugs/bug.php?id=19176
该票证有一个修补它的补丁,但尚未在pear包本身中修复。补丁:
Index: Net/URL2.php
===================================================================
--- Net/URL2.php (revision 323857)
+++ Net/URL2.php (revision )
@@ -720,7 +720,7 @@
} else {
// Merge paths (RFC 3986, section 5.2.3)
if ($this->_host !== false && $this->_path == '') {
- $target->_path = '/' . $this->_path;
+ $target->_path = '/' . $reference->_path;
} else {
$i = strrpos($this->_path, '/');
if ($i !== false) {