diff options
author | Christian Weiske <[email protected]> | 2010-11-07 13:14:08 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2010-11-08 23:09:45 +0300 |
commit | f2c6c0088bccbfc9b1259559551064b9a3648acf (patch) | |
tree | b8a959842d14837abf01aec1ff915835a883c111 | |
parent | 2d1b7139a29d417b5b59efecae1a1823f690d57a (diff) |
part of feature request #276: automatically prepend http:// if feed URL is incomplete
-rw-r--r-- | functions.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/functions.php b/functions.php index d7e1f258c..ae37e7d84 100644 --- a/functions.php +++ b/functions.php @@ -2943,6 +2943,7 @@ 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; @@ -6671,6 +6672,20 @@ 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); |