Skip to content

Commit

Permalink
Fix for replacePlaceholders with ending dot
Browse files Browse the repository at this point in the history
I noticed that placeholders at the end of a sentence are not matching. 

':causer.name has updated :properties.updatedFields.'

Removing the last dot works, but is not always nice. 

I would suggest changing the regex a little.
  • Loading branch information
Stefan-Dressler authored and freekmurze committed Jan 25, 2023
1 parent 42970e1 commit ec65a47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ActivityLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function withoutLogs(Closure $callback): mixed

protected function replacePlaceholders(string $description, ActivityContract $activity): string
{
return preg_replace_callback('/:[a-z0-9._-]+/i', function ($match) use ($activity) {
return preg_replace_callback('/:[a-z0-9._-]+(?<![.])/i', function ($match) use ($activity) {
$match = $match[0];

$attribute = Str::before(Str::after($match, ':'), '.');
Expand Down

0 comments on commit ec65a47

Please sign in to comment.