]> git.wh0rd.org Git - tt-rss.git/commitdiff
part of feature request #276: automatically prepend http:// if feed URL is incomplete
authorChristian Weiske <cweiske@cweiske.de>
Sun, 7 Nov 2010 12:14:08 +0000 (13:14 +0100)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 8 Nov 2010 20:09:45 +0000 (23:09 +0300)
functions.php

index d7e1f258cf6a68720ec0efea1ac7f5b40e042cbb..ae37e7d84327b1b36edc2f7b313effe9bff0ee77 100644 (file)
        function subscribe_to_feed($link, $url, $cat_id = 0, 
                        $auth_login = '', $auth_pass = '') {
 
+               $url   = fix_url($url);
                $parts = parse_url($url);
 
                if (!validate_feed_url($url)) return 2;
                return $url;
        }
 
+       /**
+        * Fixes incomplete URLs by prepending "http://".
+        *
+        * @param string $url Possibly incomplete URL
+        *
+        * @return string Fixed URL.
+        */
+       function fix_url($url) {
+               if (strpos($url, '://') === false) {
+                       $url = 'http://' . $url;
+               }
+               return $url;
+       }
+
        function validate_feed_url($url) {
                $parts = parse_url($url);