mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Allow locales like de_DE in removeLocaleFromPath function
Related to issue #563
This commit is contained in:
parent
eb02404d49
commit
445229976f
2 changed files with 5 additions and 3 deletions
|
@ -127,7 +127,7 @@ final class UserExtension extends AbstractExtension
|
|||
public function removeLocaleFromPath(string $path): string
|
||||
{
|
||||
//Ensure the path has the correct format
|
||||
if (!preg_match('/^\/\w{2}\//', $path)) {
|
||||
if (!preg_match('/^\/\w{2}(?:_\w{2})?\//', $path)) {
|
||||
throw new \InvalidArgumentException('The given path is not a localized path!');
|
||||
}
|
||||
|
||||
|
|
|
@ -36,16 +36,18 @@ class UserExtensionTest extends WebTestCase
|
|||
$this->service = self::getContainer()->get(UserExtension::class);
|
||||
}
|
||||
|
||||
public function removeeLocaleFromPathDataSet(): ?\Generator
|
||||
public function removeLocaleFromPathDataSet(): ?\Generator
|
||||
{
|
||||
yield ['/', '/de/'];
|
||||
yield ['/test', '/de/test'];
|
||||
yield ['/test/foo', '/en/test/foo'];
|
||||
yield ['/test/foo/bar?param1=val1¶m2=val2', '/en/test/foo/bar?param1=val1¶m2=val2'];
|
||||
//Allow de_DE
|
||||
yield ['/test/foo/bar?param1=val1¶m2=val2', '/de_DE/test/foo/bar?param1=val1¶m2=val2'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider removeeLocaleFromPathDataSet
|
||||
* @dataProvider removeLocaleFromPathDataSet
|
||||
*/
|
||||
public function testRemoveLocaleFromPath(string $expected, string $input): void
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue