Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: spark routes outputs <unknown> only when {locale} with useSupportedLocalesOnly(true) #8167

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions system/Commands/Utilities/Routes/SampleURIGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use CodeIgniter\Config\Services;
use CodeIgniter\Router\RouteCollection;
use Config\App;

/**
* Generate a sample URI path from route key regex.
Expand Down Expand Up @@ -51,6 +52,14 @@ public function get(string $routeKey): string
{
$sampleUri = $routeKey;

if (strpos($routeKey, '{locale}') !== false) {
$sampleUri = str_replace(
'{locale}',
config(App::class)->defaultLocale,
$routeKey
);
}

foreach ($this->routes->getPlaceholders() as $placeholder => $regex) {
$sample = $this->samples[$placeholder] ?? '::unknown::';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static function provideGet(): iterable
'placeholder num' => ['shop/product/([0-9]+)', 'shop/product/123'],
'placeholder segment' => ['shop/product/([^/]+)', 'shop/product/abc_123'],
'placeholder any' => ['shop/product/(.*)', 'shop/product/123/abc'],
'locale' => ['{locale}/home', 'en/home'],
'locale segment' => ['{locale}/product/([^/]+)', 'en/product/abc_123'],
'auto route' => ['home/index[/...]', 'home/index/1/2/3/4/5'],
];
}
Expand Down
Loading