Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Commit

Permalink
Removes the default version
Browse files Browse the repository at this point in the history
  • Loading branch information
Arko Elsenaar committed Oct 24, 2022
1 parent d383848 commit 6ef18ad
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 90 deletions.
9 changes: 7 additions & 2 deletions src/MessageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,21 @@ public function __invoke($message)
// 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 ($version = $matches[0] ?? "9.x") // default to 9.x if no version is given

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 "<https://laravel.com/docs/$version/$query>";

return "<https://laravel.com/docs/$version/$query>";
return "<https://laravel.com/docs/$query>";
}
}

Expand Down
176 changes: 88 additions & 88 deletions tests/MessageParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,94 +37,94 @@ public function messageInputProvider()
["bad input", false],
["homestead", false],
["docs pageDoesn'tExist", false],
["dOcS ArTiSan", "<https://laravel.com/docs/9.x/artisan>"],
["docs artisan", "<https://laravel.com/docs/9.x/artisan>"],
["docs authentication", "<https://laravel.com/docs/9.x/authentication>"],
["docs authorization", "<https://laravel.com/docs/9.x/authorization>"],
["docs billing", "<https://laravel.com/docs/9.x/billing>"],
["docs blade", "<https://laravel.com/docs/9.x/blade>"],
["docs broadcasting", "<https://laravel.com/docs/9.x/broadcasting>"],
["docs cache", "<https://laravel.com/docs/9.x/cache>"],
["docs cashier-paddle", "<https://laravel.com/docs/9.x/cashier-paddle>"],
["docs collections", "<https://laravel.com/docs/9.x/collections>"],
["docs configuration", "<https://laravel.com/docs/9.x/configuration>"],
["docs console-tests", "<https://laravel.com/docs/9.x/console-tests>"],
["docs container", "<https://laravel.com/docs/9.x/container>"],
["docs contracts", "<https://laravel.com/docs/9.x/contracts>"],
["docs contributions", "<https://laravel.com/docs/9.x/contributions>"],
["docs controllers", "<https://laravel.com/docs/9.x/controllers>"],
["docs csrf", "<https://laravel.com/docs/9.x/csrf>"],
["docs database-testing", "<https://laravel.com/docs/9.x/database-testing>"],
["docs database", "<https://laravel.com/docs/9.x/database>"],
["docs deployment", "<https://laravel.com/docs/9.x/deployment>"],
["docs documentation", "<https://laravel.com/docs/9.x/documentation>"],
["docs dusk", "<https://laravel.com/docs/9.x/dusk>"],
["docs eloquent-collections", "<https://laravel.com/docs/9.x/eloquent-collections>"],
["docs eloquent-mutators", "<https://laravel.com/docs/9.x/eloquent-mutators>"],
["docs eloquent-relationships", "<https://laravel.com/docs/9.x/eloquent-relationships>"],
["docs eloquent-resources", "<https://laravel.com/docs/9.x/eloquent-resources>"],
["docs eloquent-serialization", "<https://laravel.com/docs/9.x/eloquent-serialization>"],
["docs eloquent", "<https://laravel.com/docs/9.x/eloquent>"],
["docs encryption", "<https://laravel.com/docs/9.x/encryption>"],
["docs envoy", "<https://laravel.com/docs/9.x/envoy>"],
["docs errors", "<https://laravel.com/docs/9.x/errors>"],
["docs events", "<https://laravel.com/docs/9.x/events>"],
["docs facades", "<https://laravel.com/docs/9.x/facades>"],
["docs filesystem", "<https://laravel.com/docs/9.x/filesystem>"],
["docs fortify", "<https://laravel.com/docs/9.x/fortify>"],
["docs frontend", "<https://laravel.com/docs/9.x/frontend>"],
["docs hashing", "<https://laravel.com/docs/9.x/hashing>"],
["docs helpers", "<https://laravel.com/docs/9.x/helpers>"],
["docs homestead", "<https://laravel.com/docs/9.x/homestead>"],
["docs horizon", "<https://laravel.com/docs/9.x/horizon>"],
["docs http-client", "<https://laravel.com/docs/9.x/http-client>"],
["docs http-tests", "<https://laravel.com/docs/9.x/http-tests>"],
["docs installation", "<https://laravel.com/docs/9.x/installation>"],
["docs license", "<https://laravel.com/docs/9.x/license>"],
["docs lifecycle", "<https://laravel.com/docs/9.x/lifecycle>"],
["docs localization", "<https://laravel.com/docs/9.x/localization>"],
["docs logging", "<https://laravel.com/docs/9.x/logging>"],
["docs mail", "<https://laravel.com/docs/9.x/mail>"],
["docs middleware", "<https://laravel.com/docs/9.x/middleware>"],
["docs migrations", "<https://laravel.com/docs/9.x/migrations>"],
["docs mix", "<https://laravel.com/docs/9.x/mix>"],
["docs mocking", "<https://laravel.com/docs/9.x/mocking>"],
["docs notifications", "<https://laravel.com/docs/9.x/notifications>"],
["docs octane", "<https://laravel.com/docs/9.x/octane>"],
["docs packages", "<https://laravel.com/docs/9.x/packages>"],
["docs pagination", "<https://laravel.com/docs/9.x/pagination>"],
["docs passport", "<https://laravel.com/docs/9.x/passport>"],
["docs passwords", "<https://laravel.com/docs/9.x/passwords>"],
["docs pint", "<https://laravel.com/docs/9.x/pint>"],
["docs providers", "<https://laravel.com/docs/9.x/providers>"],
["docs queries", "<https://laravel.com/docs/9.x/queries>"],
["docs queues", "<https://laravel.com/docs/9.x/queues>"],
["docs rate-limiting", "<https://laravel.com/docs/9.x/rate-limiting>"],
["docs readme", "<https://laravel.com/docs/9.x/readme>"],
["docs redirects", "<https://laravel.com/docs/9.x/redirects>"],
["docs redis", "<https://laravel.com/docs/9.x/redis>"],
["docs releases", "<https://laravel.com/docs/9.x/releases>"],
["docs requests", "<https://laravel.com/docs/9.x/requests>"],
["docs responses", "<https://laravel.com/docs/9.x/responses>"],
["docs routing", "<https://laravel.com/docs/9.x/routing>"],
["docs sail", "<https://laravel.com/docs/9.x/sail>"],
["docs sanctum", "<https://laravel.com/docs/9.x/sanctum>"],
["docs scheduling", "<https://laravel.com/docs/9.x/scheduling>"],
["docs scout", "<https://laravel.com/docs/9.x/scout>"],
["docs seeding", "<https://laravel.com/docs/9.x/seeding>"],
["docs session", "<https://laravel.com/docs/9.x/session>"],
["docs socialite", "<https://laravel.com/docs/9.x/socialite>"],
["docs starter-kits", "<https://laravel.com/docs/9.x/starter-kits>"],
["docs structure", "<https://laravel.com/docs/9.x/structure>"],
["docs telescope", "<https://laravel.com/docs/9.x/telescope>"],
["docs testing", "<https://laravel.com/docs/9.x/testing>"],
["docs upgrade", "<https://laravel.com/docs/9.x/upgrade>"],
["docs urls", "<https://laravel.com/docs/9.x/urls>"],
["docs valet", "<https://laravel.com/docs/9.x/valet>"],
["docs validation", "<https://laravel.com/docs/9.x/validation>"],
["docs verification", "<https://laravel.com/docs/9.x/verification>"],
["docs views", "<https://laravel.com/docs/9.x/views>"],
["docs vite", "<https://laravel.com/docs/9.x/vite>"],
["dOcS ArTiSan", "<https://laravel.com/docs/artisan>"],
["docs artisan", "<https://laravel.com/docs/artisan>"],
["docs authentication", "<https://laravel.com/docs/authentication>"],
["docs authorization", "<https://laravel.com/docs/authorization>"],
["docs billing", "<https://laravel.com/docs/billing>"],
["docs blade", "<https://laravel.com/docs/blade>"],
["docs broadcasting", "<https://laravel.com/docs/broadcasting>"],
["docs cache", "<https://laravel.com/docs/cache>"],
["docs cashier-paddle", "<https://laravel.com/docs/cashier-paddle>"],
["docs collections", "<https://laravel.com/docs/collections>"],
["docs configuration", "<https://laravel.com/docs/configuration>"],
["docs console-tests", "<https://laravel.com/docs/console-tests>"],
["docs container", "<https://laravel.com/docs/container>"],
["docs contracts", "<https://laravel.com/docs/contracts>"],
["docs contributions", "<https://laravel.com/docs/contributions>"],
["docs controllers", "<https://laravel.com/docs/controllers>"],
["docs csrf", "<https://laravel.com/docs/csrf>"],
["docs database-testing", "<https://laravel.com/docs/database-testing>"],
["docs database", "<https://laravel.com/docs/database>"],
["docs deployment", "<https://laravel.com/docs/deployment>"],
["docs documentation", "<https://laravel.com/docs/documentation>"],
["docs dusk", "<https://laravel.com/docs/dusk>"],
["docs eloquent-collections", "<https://laravel.com/docs/eloquent-collections>"],
["docs eloquent-mutators", "<https://laravel.com/docs/eloquent-mutators>"],
["docs eloquent-relationships", "<https://laravel.com/docs/eloquent-relationships>"],
["docs eloquent-resources", "<https://laravel.com/docs/eloquent-resources>"],
["docs eloquent-serialization", "<https://laravel.com/docs/eloquent-serialization>"],
["docs eloquent", "<https://laravel.com/docs/eloquent>"],
["docs encryption", "<https://laravel.com/docs/encryption>"],
["docs envoy", "<https://laravel.com/docs/envoy>"],
["docs errors", "<https://laravel.com/docs/errors>"],
["docs events", "<https://laravel.com/docs/events>"],
["docs facades", "<https://laravel.com/docs/facades>"],
["docs filesystem", "<https://laravel.com/docs/filesystem>"],
["docs fortify", "<https://laravel.com/docs/fortify>"],
["docs frontend", "<https://laravel.com/docs/frontend>"],
["docs hashing", "<https://laravel.com/docs/hashing>"],
["docs helpers", "<https://laravel.com/docs/helpers>"],
["docs homestead", "<https://laravel.com/docs/homestead>"],
["docs horizon", "<https://laravel.com/docs/horizon>"],
["docs http-client", "<https://laravel.com/docs/http-client>"],
["docs http-tests", "<https://laravel.com/docs/http-tests>"],
["docs installation", "<https://laravel.com/docs/installation>"],
["docs license", "<https://laravel.com/docs/license>"],
["docs lifecycle", "<https://laravel.com/docs/lifecycle>"],
["docs localization", "<https://laravel.com/docs/localization>"],
["docs logging", "<https://laravel.com/docs/logging>"],
["docs mail", "<https://laravel.com/docs/mail>"],
["docs middleware", "<https://laravel.com/docs/middleware>"],
["docs migrations", "<https://laravel.com/docs/migrations>"],
["docs mix", "<https://laravel.com/docs/mix>"],
["docs mocking", "<https://laravel.com/docs/mocking>"],
["docs notifications", "<https://laravel.com/docs/notifications>"],
["docs octane", "<https://laravel.com/docs/octane>"],
["docs packages", "<https://laravel.com/docs/packages>"],
["docs pagination", "<https://laravel.com/docs/pagination>"],
["docs passport", "<https://laravel.com/docs/passport>"],
["docs passwords", "<https://laravel.com/docs/passwords>"],
["docs pint", "<https://laravel.com/docs/pint>"],
["docs providers", "<https://laravel.com/docs/providers>"],
["docs queries", "<https://laravel.com/docs/queries>"],
["docs queues", "<https://laravel.com/docs/queues>"],
["docs rate-limiting", "<https://laravel.com/docs/rate-limiting>"],
["docs readme", "<https://laravel.com/docs/readme>"],
["docs redirects", "<https://laravel.com/docs/redirects>"],
["docs redis", "<https://laravel.com/docs/redis>"],
["docs releases", "<https://laravel.com/docs/releases>"],
["docs requests", "<https://laravel.com/docs/requests>"],
["docs responses", "<https://laravel.com/docs/responses>"],
["docs routing", "<https://laravel.com/docs/routing>"],
["docs sail", "<https://laravel.com/docs/sail>"],
["docs sanctum", "<https://laravel.com/docs/sanctum>"],
["docs scheduling", "<https://laravel.com/docs/scheduling>"],
["docs scout", "<https://laravel.com/docs/scout>"],
["docs seeding", "<https://laravel.com/docs/seeding>"],
["docs session", "<https://laravel.com/docs/session>"],
["docs socialite", "<https://laravel.com/docs/socialite>"],
["docs starter-kits", "<https://laravel.com/docs/starter-kits>"],
["docs structure", "<https://laravel.com/docs/structure>"],
["docs telescope", "<https://laravel.com/docs/telescope>"],
["docs testing", "<https://laravel.com/docs/testing>"],
["docs upgrade", "<https://laravel.com/docs/upgrade>"],
["docs urls", "<https://laravel.com/docs/urls>"],
["docs valet", "<https://laravel.com/docs/valet>"],
["docs validation", "<https://laravel.com/docs/validation>"],
["docs verification", "<https://laravel.com/docs/verification>"],
["docs views", "<https://laravel.com/docs/views>"],
["docs vite", "<https://laravel.com/docs/vite>"],
["docs 9.x csrf", "<https://laravel.com/docs/9.x/csrf>"],
["docs 8.x csrf", "<https://laravel.com/docs/8.x/csrf>"],
["docs 10.x csrf", false],
Expand Down

0 comments on commit 6ef18ad

Please sign in to comment.