]> git.mxchange.org Git - friendica.git/commitdiff
Making the tests happy
authorMichael <heluecht@pirati.ca>
Sat, 24 Nov 2018 09:01:10 +0000 (09:01 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 24 Nov 2018 09:01:10 +0000 (09:01 +0000)
src/Network/CurlResult.php

index b92c0bc45fff42df342eb392008a228894056455..b2587799d19bdc9b9bc9ac495cbf428a777b9cec 100644 (file)
@@ -160,19 +160,19 @@ class CurlResult
                }
 
                if ($this->returnCode == 301 || $this->returnCode == 302 || $this->returnCode == 303 || $this->returnCode== 307) {
-                       $redirect_parts = parse_url($this->info['redirect_url']);
+                       $redirect_parts = parse_url(defaults($this->info, 'redirect_url', ''));
                        if (preg_match('/(Location:|URI:)(.*?)\n/i', $this->header, $matches)) {
                                $redirect_parts = array_merge($redirect_parts, parse_url(trim(array_pop($matches))));
                        }
 
-                       $parts = parse_url($this->info['url']);
+                       $parts = parse_url(defaults($this->info, 'url', ''));
 
-                       if (empty($redirect_parts['scheme']) && !empty($parts['scheme'])) {
-                               $redirect_parts['scheme'] = $parts['scheme'];
-                       }
-
-                       if (empty($redirect_parts['host']) && !empty($parts['host'])) {
-                               $redirect_parts['host'] = $parts['host'];
+                       /// @todo Checking the corresponding RFC which parts of a redirect can be ommitted.
+                       $components = ['scheme', 'host', 'path', 'query', 'fragment'];
+                       foreach ($components as $component) {
+                               if (empty($redirect_parts[$component]) && !empty($parts[$component])) {
+                                       $redirect_parts[$component] = $parts[$component];
+                               }
                        }
 
                        $this->redirectUrl = Network::unparseURL($redirect_parts);