Commit 1502f1b
authored
fix: Implemented whole word matching in ProfanityAnalyser class (#81)
Example in portuguese:
'Colar de pérola' would get incorrectly flagged as profanity because it
contains the last 4 chars that is a [bad word in pt_BR
config](https://github.com/pestphp/pest-plugin-profanity/blob/06c77bb058ef577ff1e744ba853c08c015b31792/src/Config/profanities/pt_BR.php#L114).
After this fix: PASS No profanity found in your application!
```
\p{L} matches any Unicode letter.
(?<!\p{L}) ensures the character before isn’t a letter.
(?!\p{L}) ensures the character after isn’t a letter.
u flag = Unicode mode
i flag = case-insensitive
```1 parent 06c77bb commit 1502f1b
1 file changed
+7
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
68 | 66 | | |
69 | 67 | | |
70 | 68 | | |
| |||
0 commit comments