diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 935c413cd6c0..1e0f3a7db3bf 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -621,7 +621,7 @@ protected function concatPathToUrl($url, $path) } /** - * Replace the scheme and host of the given UriInterface with values from the given URL. + * Replace the scheme, host and port of the given UriInterface with values from the given URL. * * @param \Psr\Http\Message\UriInterface $uri * @param string $url @@ -631,7 +631,10 @@ protected function replaceBaseUrl($uri, $url) { $parsed = parse_url($url); - return $uri->withScheme($parsed['scheme'])->withHost($parsed['host']); + return $uri + ->withScheme($parsed['scheme']) + ->withHost($parsed['host']) + ->withPort($parsed['port'] ?? null); } /**