comparison vendor/symfony/dom-crawler/AbstractUriElement.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
40 * 40 *
41 * @throws \InvalidArgumentException if the node is not a link 41 * @throws \InvalidArgumentException if the node is not a link
42 */ 42 */
43 public function __construct(\DOMElement $node, $currentUri, $method = 'GET') 43 public function __construct(\DOMElement $node, $currentUri, $method = 'GET')
44 { 44 {
45 if (!in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) { 45 if (!\in_array(strtolower(substr($currentUri, 0, 4)), ['http', 'file'])) {
46 throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri)); 46 throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri));
47 } 47 }
48 48
49 $this->setNode($node); 49 $this->setNode($node);
50 $this->method = $method ? strtoupper($method) : null; 50 $this->method = $method ? strtoupper($method) : null;
112 if ('/' === $uri[0]) { 112 if ('/' === $uri[0]) {
113 return $baseUri.$uri; 113 return $baseUri.$uri;
114 } 114 }
115 115
116 // relative path 116 // relative path
117 $path = parse_url(substr($this->currentUri, strlen($baseUri)), PHP_URL_PATH); 117 $path = parse_url(substr($this->currentUri, \strlen($baseUri)), PHP_URL_PATH);
118 $path = $this->canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri); 118 $path = $this->canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri);
119 119
120 return $baseUri.('' === $path || '/' !== $path[0] ? '/' : '').$path; 120 return $baseUri.('' === $path || '/' !== $path[0] ? '/' : '').$path;
121 } 121 }
122 122
142 142
143 if ('.' === substr($path, -1)) { 143 if ('.' === substr($path, -1)) {
144 $path .= '/'; 144 $path .= '/';
145 } 145 }
146 146
147 $output = array(); 147 $output = [];
148 148
149 foreach (explode('/', $path) as $segment) { 149 foreach (explode('/', $path) as $segment) {
150 if ('..' === $segment) { 150 if ('..' === $segment) {
151 array_pop($output); 151 array_pop($output);
152 } elseif ('.' !== $segment) { 152 } elseif ('.' !== $segment) {