]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/Probe.php
Update function / rearrange tab order
[friendica.git] / src / Network / Probe.php
index bd98f39103bc2b8da1ce388a1939e4fec961e731..a0887d5cba877cb5187acccdf6c09017c261b1a6 100644 (file)
@@ -341,12 +341,10 @@ class Probe
         * @param string  $uri     Address that should be probed
         * @param string  $network Test for this specific network
         * @param integer $uid     User ID for the probe (only used for mails)
-        * @param boolean $cache   Use cached values?
         *
         * @return array uri data
         * @throws HTTPException\InternalServerErrorException
         * @throws \ImagickException
-        * @todo Choice: implement $cache parameter or remove documentation
         */
        public static function uri(string $uri, string $network = '', int $uid = -1): array
        {
@@ -417,14 +415,19 @@ class Probe
                        }
                }
 
-               if (!empty($data['baseurl']) && empty($data['gsid'])) {
-                       $data['gsid'] = GServer::getID($data['baseurl']);
-               }
-
                if (empty($data['network'])) {
                        $data['network'] = Protocol::PHANTOM;
                }
 
+               $baseurl = parse_url($data['url'], PHP_URL_SCHEME) . '://' . parse_url($data['url'], PHP_URL_HOST);
+               if (empty($data['baseurl']) && ($data['network'] == Protocol::ACTIVITYPUB) && (rtrim($data['url'], '/') == $baseurl)) {
+                       $data['baseurl'] = $baseurl;
+               }
+
+               if (!empty($data['baseurl']) && empty($data['gsid'])) {
+                       $data['gsid'] = GServer::getID($data['baseurl']);
+               }       
+
                // Ensure that local connections always are DFRN
                if (($network == '') && ($data['network'] != Protocol::PHANTOM) && (self::ownHost($data['baseurl'] ?? '') || self::ownHost($data['url']))) {
                        $data['network'] = Protocol::DFRN;