mirror of
https://github.com/friendica/friendica
synced 2025-04-25 22:30:10 +00:00
Issue 8866: Fix fetching feed links with missing base
This commit is contained in:
parent
09bb0dff42
commit
81928727f2
2 changed files with 24 additions and 0 deletions
|
@ -625,6 +625,26 @@ class Network
|
|||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a missing base path (scheme and host) to a given url
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $basepath
|
||||
* @return string url
|
||||
*/
|
||||
public static function addBasePath(string $url, string $basepath)
|
||||
{
|
||||
if (!empty(parse_url($url, PHP_URL_SCHEME)) || empty(parse_url($basepath, PHP_URL_SCHEME)) || empty($url) || empty(parse_url($url))) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
$base = ['scheme' => parse_url($basepath, PHP_URL_SCHEME),
|
||||
'host' => parse_url($basepath, PHP_URL_HOST)];
|
||||
|
||||
$parts = array_merge($base, parse_url('/' . ltrim($url, '/')));
|
||||
return self::unparseURL($parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the original URL of the provided URL
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue