diff --git a/src/MessageParser.php b/src/MessageParser.php index cd95b1b..426da5b 100644 --- a/src/MessageParser.php +++ b/src/MessageParser.php @@ -95,14 +95,29 @@ class MessageParser { public function __invoke($message) { $content = strtolower($message->content); + // Grab the first 4 chars for our trigger $trigger = substr($content, 0, 5); + // Grab everything after the first 5 chars $query = substr($content, 5); + // Check if version is available in command + $pattern = '/\b([6-9]\.x)\b/'; // only match 6.x to 9.x + preg_match($pattern, $query, $matches); + + if ($matches) { + $query = preg_replace($pattern, '', $query); + $version = $matches[0]; + } + + $query = trim($query); + if($trigger === "docs ") { if(in_array($query, $this->docs)){ + if (isset($version)) + return ""; return ""; } diff --git a/tests/MessageParserTest.php b/tests/MessageParserTest.php index e76b58e..2fa1396 100644 --- a/tests/MessageParserTest.php +++ b/tests/MessageParserTest.php @@ -125,6 +125,10 @@ public function messageInputProvider() ["docs verification", ""], ["docs views", ""], ["docs vite", ""], + ["docs 9.x csrf", ""], + ["docs 8.x csrf", ""], + ["docs 10.x csrf", false], + ["docs csrf 9.x", ""], ]; } } \ No newline at end of file