Skip to content

Commit 016754c

Browse files
authored
Merge pull request #16 from JonPurvis/remove-tolerated-config
Remove tolerated config
2 parents 2d02bac + d556d4f commit 016754c

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/Rules/Clean.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
2323

2424
foreach ($locales as $locale) {
2525
$profanities = Config::get($this->configFileName($locale));
26-
$tolerated = Config::get('profanify-tolerated');
2726

28-
if (Str::contains(Str::lower(Str::remove($tolerated, $value)), $profanities)) {
29-
$fail(trans('message'))->translate([
30-
'attribute' => $attribute,
31-
], $this->getLocaleValue($locale));
27+
$lowerValue = Str::lower($value);
28+
foreach ($profanities as $profanity) {
29+
if (preg_match('/\b' . preg_quote($profanity, '/') . '\b/i', $lowerValue)) {
30+
$fail(trans('message'))->translate([
31+
'attribute' => $attribute,
32+
], $this->getLocaleValue($locale));
33+
break;
34+
}
3235
}
3336
}
3437
}

src/SqueakyServiceProvider.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public function boot(): void
2626
$this->mergeConfigFrom($profanifyBasePath.'/profanities/ja.php', 'profanify-ja');
2727
$this->mergeConfigFrom($profanifyBasePath.'/profanities/nl.php', 'profanify-nl');
2828
$this->mergeConfigFrom($profanifyBasePath.'/profanities/pt_BR.php', 'profanify-pt_BR');
29-
30-
// General Configs
31-
$this->mergeConfigFrom($profanifyBasePath.'/tolerated.php', 'profanify-tolerated');
3229
}
3330

3431
public function configurePackage(Package $package): void

0 commit comments

Comments
 (0)