From d4613cd15805691f0eb4ce9d4b9468a0109f164d Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Tue, 21 Jan 2020 14:19:54 +0100 Subject: [PATCH 1/2] Add the testcase that covers URL ending with slash --- tests/Support/ConfigurationUrlParserTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Support/ConfigurationUrlParserTest.php b/tests/Support/ConfigurationUrlParserTest.php index c042cf1d210b..4e6439d4a164 100644 --- a/tests/Support/ConfigurationUrlParserTest.php +++ b/tests/Support/ConfigurationUrlParserTest.php @@ -352,6 +352,23 @@ public function databaseUrls() 'password' => 'asdfqwer1234asdf', ], ], + 'Redis example where URL ends with "/" and database is not present' => [ + [ + 'url' => 'redis://h:asdfqwer1234asdf@ec2-111-1-1-1.compute-1.amazonaws.com:111/', + 'host' => '127.0.0.1', + 'password' => null, + 'port' => 6379, + 'database' => 2, + ], + [ + 'driver' => 'redis', + 'host' => 'ec2-111-1-1-1.compute-1.amazonaws.com', + 'port' => 111, + 'database' => 2, + 'username' => 'h', + 'password' => 'asdfqwer1234asdf', + ], + ], ]; } } From babcd52aa59cd8ee88db38d16b89b0cae632dc21 Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Tue, 21 Jan 2020 14:21:16 +0100 Subject: [PATCH 2/2] Ignore path when database is not present --- src/Illuminate/Support/ConfigurationUrlParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Support/ConfigurationUrlParser.php b/src/Illuminate/Support/ConfigurationUrlParser.php index 8ed1b8b90f8f..e67e469ed15e 100644 --- a/src/Illuminate/Support/ConfigurationUrlParser.php +++ b/src/Illuminate/Support/ConfigurationUrlParser.php @@ -95,7 +95,7 @@ protected function getDatabase($url) { $path = $url['path'] ?? null; - return $path ? substr($path, 1) : null; + return $path && $path !== '/' ? substr($path, 1) : null; } /**