[DomCrawler] Fixed URIs being incorrectly generated
When the path is not ending with a slash and the form/link has only ?get=params then the last bit of the path was incorrectly stripped
This commit is contained in:
parent
a6da0fb0c4
commit
1719bfb871
@ -567,10 +567,6 @@ class Crawler extends \SplObjectStorage
|
||||
|
||||
$path = parse_url($uri, PHP_URL_PATH);
|
||||
|
||||
if ('/' !== substr($path, -1)) {
|
||||
$path = substr($path, 0, strrpos($path, '/') + 1);
|
||||
}
|
||||
|
||||
return array(preg_replace('#^(.*?//[^/]+)\/.*$#', '$1', $uri), $path);
|
||||
}
|
||||
|
||||
|
@ -176,8 +176,13 @@ class Form implements \ArrayAccess
|
||||
$uri .= $sep.$queryString;
|
||||
}
|
||||
|
||||
$path = $this->path;
|
||||
if ('?' !== substr($uri, 0, 1) && '/' !== substr($path, -1)) {
|
||||
$path = substr($path, 0, strrpos($path, '/') + 1);
|
||||
}
|
||||
|
||||
if ($uri && '/' !== $uri[0] && !$urlHaveScheme) {
|
||||
$uri = $this->path.$uri;
|
||||
$uri = $path.$uri;
|
||||
}
|
||||
|
||||
if ($absolute && null !== $this->host && !$urlHaveScheme) {
|
||||
|
@ -67,8 +67,13 @@ class Link
|
||||
$uri = $this->node->getAttribute('href');
|
||||
$urlHaveScheme = 'http' === substr($uri, 0, 4);
|
||||
|
||||
$path = $this->path;
|
||||
if ('?' !== substr($uri, 0, 1) && '/' !== substr($path, -1)) {
|
||||
$path = substr($path, 0, strrpos($path, '/') + 1);
|
||||
}
|
||||
|
||||
if ($uri && '/' !== $uri[0] && !$urlHaveScheme) {
|
||||
$uri = $this->path.$uri;
|
||||
$uri = $path.$uri;
|
||||
}
|
||||
|
||||
if ($absolute && null !== $this->host && !$urlHaveScheme) {
|
||||
|
Reference in New Issue
Block a user