From f2c6c0088bccbfc9b1259559551064b9a3648acf Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sun, 7 Nov 2010 13:14:08 +0100 Subject: [PATCH] part of feature request #276: automatically prepend http:// if feed URL is incomplete --- functions.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/functions.php b/functions.php index d7e1f258..ae37e7d8 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); -- 2.39.5