]> git.mxchange.org Git - friendica.git/commitdiff
Drupal doesn't provide absolute URL on feed. Fix to allow importing Drupal "contacts".
authorFriendika <info@friendika.com>
Sun, 22 May 2011 02:15:55 +0000 (19:15 -0700)
committerFriendika <info@friendika.com>
Sun, 22 May 2011 02:15:55 +0000 (19:15 -0700)
include/Scrape.php

index 21e6bd01ff368fa3ad31ce6ff761c64acb56739c..7fc0c964bfe5ad54c1e74d99100ec2b1a627168b 100644 (file)
@@ -241,6 +241,17 @@ function scrape_feed($url) {
                }
        }
 
+
+       $head = $dom->getElementsByTagName('base');
+       if($head) {
+               foreach($head as $head0) {
+                       $basename = $head0->getAttribute('href');
+                       break;
+               }
+       }
+       if(! $basename)
+               $basename = substr($url,0,strrpos($url,'/')) . '/';
+
        $items = $dom->getElementsByTagName('link');
 
        // get Atom/RSS link elements, take the first one of either.
@@ -259,6 +270,13 @@ function scrape_feed($url) {
                }       
        }
 
+       // Drupal and perhaps others only provide relative URL's. Turn them into absolute.
+
+       if(x($ret,'feed_atom') && (! strstr($ret['feed_atom'],'://')))
+               $ret['feed_atom'] = $basename . $ret['feed_atom'];
+       if(x($ret,'feed_rss') && (! strstr($ret['feed_rss'],'://')))
+               $ret['feed_rss'] = $basename . $ret['feed_rss'];
+
        return $ret;
 }}