part of feature request #276: automatically prepend http:// if feed URL is incomplete
This commit is contained in:
parent
2d1b7139a2
commit
f2c6c0088b
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue