]> git.wh0rd.org - tt-rss.git/blobdiff - functions.php
part of feature request #276: automatically prepend http:// if feed URL is incomplete
[tt-rss.git] / 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);