[2.3] [DomCrawler] adds schema relative URL support to link
This commit is contained in:
parent
fb7004baab
commit
c6fe27f63e
|
@ -120,6 +120,11 @@ class Link
|
|||
return $baseUri.$uri;
|
||||
}
|
||||
|
||||
// absolute URL with relative schema
|
||||
if (0 === strpos($uri, '//')) {
|
||||
return preg_replace('#^([^/]*)//.*$#', '$1', $this->currentUri).$uri;
|
||||
}
|
||||
|
||||
// absolute path
|
||||
if ('/' === $uri[0]) {
|
||||
return preg_replace('#^(.*?//[^/]+)(?:\/.*)?$#', '$1', $this->currentUri).$uri;
|
||||
|
|
|
@ -94,6 +94,10 @@ class LinkTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
array('http://login.foo.com/foo', 'http://localhost/bar/', 'http://login.foo.com/foo'),
|
||||
|
||||
// tests schema relative URL (issue #7169)
|
||||
array('//login.foo.com/foo', 'http://localhost/bar/', 'http://login.foo.com/foo'),
|
||||
array('//login.foo.com/foo', 'https://localhost/bar/', 'https://login.foo.com/foo'),
|
||||
|
||||
array('?foo=2', 'http://localhost?foo=1', 'http://localhost?foo=2'),
|
||||
array('?foo=2', 'http://localhost/?foo=1', 'http://localhost/?foo=2'),
|
||||
array('?foo=2', 'http://localhost/bar?foo=1', 'http://localhost/bar?foo=2'),
|
||||
|
|
Reference in New Issue