Complete incomplete URL during feed import

This commit is contained in:
Michael 2017-10-16 20:31:13 +00:00
parent a0530d1066
commit 2a28591415
3 changed files with 103 additions and 10 deletions

View file

@ -1003,3 +1003,34 @@ function matching_url($url1, $url2) {
return normalise_link($match);
}
/**
* @brief Glue url parts together
*
* @param array $parsed URL parts
*
* @return string The glued URL
*/
function unParseUrl($parsed) {
$get = function ($key) use ($parsed) {
return isset($parsed[$key]) ? $parsed[$key] : null;
};
$pass = $get('pass');
$user = $get('user');
$userinfo = $pass !== null ? "$user:$pass" : $user;
$port = $get('port');
$scheme = $get('scheme');
$query = $get('query');
$fragment = $get('fragment');
$authority =
($userinfo !== null ? $userinfo."@" : '') .
$get('host') .
($port ? ":$port" : '');
return (strlen($scheme) ? $scheme.":" : '') .
(strlen($authority) ? "//".$authority : '') .
$get('path') .
(strlen($query) ? "?".$query : '') .
(strlen($fragment) ? "#".$fragment : '');
}