From a7b677bb39b3e414f9cb8bac2874584f2de58a5e Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 7 Aug 2024 17:19:14 +0100 Subject: [PATCH 1/3] Add failing test --- tests/Rules/HandleTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Rules/HandleTest.php b/tests/Rules/HandleTest.php index d518ef50cb..1802979704 100644 --- a/tests/Rules/HandleTest.php +++ b/tests/Rules/HandleTest.php @@ -22,6 +22,7 @@ public function it_validates_handles() $this->assertPasses('foo1'); $this->assertPasses('foo123'); $this->assertPasses('foo123_20bar'); + $this->assertPasses('FooBar'); $this->assertFails('foo-bar'); $this->assertFails('_foo'); From 5ee375df4b7f2c172dff0c7b6e62bce6af79e521 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 7 Aug 2024 17:20:43 +0100 Subject: [PATCH 2/3] Adjust the regex to allow for uppercase characters --- src/Rules/Handle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rules/Handle.php b/src/Rules/Handle.php index 73bfe93dfe..9a3c06514f 100644 --- a/src/Rules/Handle.php +++ b/src/Rules/Handle.php @@ -9,7 +9,7 @@ class Handle implements ValidationRule { public function validate(string $attribute, mixed $value, Closure $fail): void { - if (! preg_match('/^[a-z][a-z0-9]*(?:_{0,1}[a-z0-9])*$/', $value)) { + if (! preg_match('/^[a-zA-Z][a-zA-Z0-9]*(?:_{0,1}[a-zA-Z0-9])*$/', $value)) { $fail('statamic::validation.handle')->translate(); } } From 38095909913a2fcc97072392ef6ebcf2355019e7 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 7 Aug 2024 17:21:00 +0100 Subject: [PATCH 3/3] This should be `it_validates_slugs` instead. --- tests/Rules/SlugTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Rules/SlugTest.php b/tests/Rules/SlugTest.php index 7def836a2b..e31bfb1d82 100644 --- a/tests/Rules/SlugTest.php +++ b/tests/Rules/SlugTest.php @@ -13,7 +13,7 @@ class SlugTest extends TestCase protected static $customRule = Slug::class; #[Test] - public function it_validates_handles() + public function it_validates_slugs() { $this->assertPasses('foo'); $this->assertPasses('foo-bar');