Simplified how the custom slugs are processed, allowing more characters in the process

This commit is contained in:
Alejandro Celaya
2022-01-09 21:02:23 +01:00
parent d2fef20239
commit e47c90c645
5 changed files with 18 additions and 33 deletions

View File

@@ -30,34 +30,43 @@ class ShortUrlMetaTest extends TestCase
public function provideInvalidData(): iterable
{
yield [[]];
yield [[
ShortUrlInputFilter::LONG_URL => 'foo',
ShortUrlInputFilter::VALID_SINCE => '',
ShortUrlInputFilter::VALID_UNTIL => '',
ShortUrlInputFilter::CUSTOM_SLUG => 'foobar',
ShortUrlInputFilter::MAX_VISITS => 'invalid',
]];
yield [[
ShortUrlInputFilter::LONG_URL => 'foo',
ShortUrlInputFilter::VALID_SINCE => '2017',
ShortUrlInputFilter::MAX_VISITS => 5,
]];
yield [[
ShortUrlInputFilter::LONG_URL => 'foo',
ShortUrlInputFilter::VALID_SINCE => new stdClass(),
ShortUrlInputFilter::VALID_UNTIL => 'foo',
]];
yield [[
ShortUrlInputFilter::LONG_URL => 'foo',
ShortUrlInputFilter::VALID_UNTIL => 500,
ShortUrlInputFilter::DOMAIN => 4,
]];
yield [[
ShortUrlInputFilter::LONG_URL => 'foo',
ShortUrlInputFilter::SHORT_CODE_LENGTH => 3,
]];
yield [[
ShortUrlInputFilter::LONG_URL => 'foo',
ShortUrlInputFilter::CUSTOM_SLUG => '/',
]];
yield [[
ShortUrlInputFilter::LONG_URL => 'foo',
ShortUrlInputFilter::CUSTOM_SLUG => '',
]];
yield [[
ShortUrlInputFilter::LONG_URL => 'foo',
ShortUrlInputFilter::CUSTOM_SLUG => ' ',
]];
yield [[
@@ -92,12 +101,15 @@ class ShortUrlMetaTest extends TestCase
public function provideCustomSlugs(): iterable
{
yield ['🔥', '🔥'];
yield ['🦣 🍅', '🦣-🍅'];
yield ['foobar', 'foobar'];
yield ['foo bar', 'foo-bar'];
yield ['foo bar baz', 'foo-bar-baz'];
yield ['foo bar-baz', 'foo-bar-baz'];
yield ['wp-admin.php', 'wp-admin.php'];
yield ['UPPER_lower', 'UPPER_lower'];
yield ['more~url_special.chars', 'more~url_special.chars'];
yield ['äéñ', 'äen'];
yield ['구글', '구글'];
yield ['グーグル', 'グーグル'];
yield ['谷歌', '谷歌'];