Php 简单的html dom和Net URL2规范化相对路径
我正在尝试使用和规范化到完整URL的相对路径,像这样的路径由脚本规范化,例如:Php 简单的html dom和Net URL2规范化相对路径,php,relative-path,simple-html-dom,Php,Relative Path,Simple Html Dom,我正在尝试使用和规范化到完整URL的相对路径,像这样的路径由脚本规范化,例如:src=“/my\u path”,但是像这样的路径:src=“my\u path”不是!如何规范化这样的路径 例如: $uri = new Net_URL2("http://test.com"); print $uri->resolve('/my_path') . "\n"; // works print $uri->resolve('my_path') . "\n"; // doesn't work!
src=“/my\u path”
,但是像这样的路径:src=“my\u path”
不是!如何规范化这样的路径
例如:
$uri = new Net_URL2("http://test.com");
print $uri->resolve('/my_path') . "\n"; // works
print $uri->resolve('my_path') . "\n"; // doesn't work!
您描述的是Net_URL2中的一个已知错误: 票证有一个补丁可以修复它,但是它还没有在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) {
您描述的是Net_URL2中的一个已知错误: 票证有一个补丁可以修复它,但是它还没有在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) {