From 15a1f56b226df12ccc4370dc673c38352e0838fa Mon Sep 17 00:00:00 2001 From: ozh Date: Sun, 10 Jan 2016 12:59:04 +0100 Subject: [PATCH] Sync with http_build_url --- includes/http_build_url/http_build_url.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/http_build_url/http_build_url.php b/includes/http_build_url/http_build_url.php index 95ed0fb..0dfdbba 100644 --- a/includes/http_build_url/http_build_url.php +++ b/includes/http_build_url/http_build_url.php @@ -92,6 +92,8 @@ function http_build_url($url, $parts = array(), $flags = HTTP_URL_REPLACE, &$new } else { if (isset($parts['path']) && ($flags & HTTP_URL_JOIN_PATH)) { if (isset($url['path']) && substr($parts['path'], 0, 1) !== '/') { + // Workaround for trailing slashes + $url['path'] .= 'a'; $url['path'] = rtrim( str_replace(basename($url['path']), '', $url['path']), '/' @@ -118,7 +120,7 @@ function http_build_url($url, $parts = array(), $flags = HTTP_URL_REPLACE, &$new } } - if (isset($url['path']) && substr($url['path'], 0, 1) !== '/') { + if (isset($url['path']) && $url['path'] !== '' && substr($url['path'], 0, 1) !== '/') { $url['path'] = '/' . $url['path']; } @@ -131,11 +133,11 @@ function http_build_url($url, $parts = array(), $flags = HTTP_URL_REPLACE, &$new $parsed_string = ''; - if (isset($url['scheme'])) { + if (!empty($url['scheme'])) { $parsed_string .= $url['scheme'] . '://'; } - if (isset($url['user'])) { + if (!empty($url['user'])) { $parsed_string .= $url['user']; if (isset($url['pass'])) { @@ -145,25 +147,23 @@ function http_build_url($url, $parts = array(), $flags = HTTP_URL_REPLACE, &$new $parsed_string .= '@'; } - if (isset($url['host'])) { + if (!empty($url['host'])) { $parsed_string .= $url['host']; } - if (isset($url['port'])) { + if (!empty($url['port'])) { $parsed_string .= ':' . $url['port']; } if (!empty($url['path'])) { $parsed_string .= $url['path']; - } else { - $parsed_string .= '/'; } - if (isset($url['query'])) { + if (!empty($url['query'])) { $parsed_string .= '?' . $url['query']; } - if (isset($url['fragment'])) { + if (!empty($url['fragment'])) { $parsed_string .= '#' . $url['fragment']; } -- 2.45.0