From ebf406973ee69c378be418a9ca823da86519d994 Mon Sep 17 00:00:00 2001 From: Jedy Matt Tabasco Date: Sun, 25 Sep 2022 12:49:00 +0800 Subject: [PATCH] Detect services with only preceding whitespace and not include any whitespace character --- src/Console/SailEnvCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/SailEnvCommand.php b/src/Console/SailEnvCommand.php index f7ebf8f..d17c62b 100644 --- a/src/Console/SailEnvCommand.php +++ b/src/Console/SailEnvCommand.php @@ -59,7 +59,7 @@ protected function getServicesFromDockerCompose(): array $dockerComposeContent = file_get_contents($this->laravel->basePath('docker-compose.yml')); $regex = '/'.implode('|', array_map(function ($service) { - return '(?<=\s)'.$service.'(?=:)'; // Match service name followed by ':' (e.g. mysql:) and preceded by whitespace + return '(?<=[^\S]\s)'.$service.'(?=:)'; // Match service name followed by ':' (e.g. mysql:) and preceded only by whitespace }, $this->services)).'/'; preg_match_all($regex, $dockerComposeContent, $matches);