Skip to content

Commit 03d3235

Browse files
authored
Merge pull request #1237 from hydephp/bugfixes
Normalize internal author array keys to lowercase to make author usernames case-insensitive
2 parents 260fc53 + d12f0e9 commit 03d3235

File tree

1 file changed

+3
-2
lines changed
  • packages/framework/src/Framework/Features/Blogging/Models

1 file changed

+3
-2
lines changed

packages/framework/src/Framework/Features/Blogging/Models/PostAuthor.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Hyde\Facades\Author;
99
use Hyde\Facades\Config;
1010
use Illuminate\Support\Collection;
11+
use function strtolower;
1112
use function is_string;
1213

1314
/**
@@ -65,14 +66,14 @@ public static function getOrCreate(string|array $data): static
6566
/** Get an Author from the config, or create it. */
6667
public static function get(string $username): static
6768
{
68-
return static::all()->firstWhere('username', $username) ?? Author::create($username);
69+
return static::all()->firstWhere('username', strtolower($username)) ?? Author::create($username);
6970
}
7071

7172
/** @return \Illuminate\Support\Collection<\Hyde\Framework\Features\Blogging\Models\PostAuthor> */
7273
public static function all(): Collection
7374
{
7475
return (new Collection(Config::getArray('hyde.authors', [])))->mapWithKeys(function (self $author): array {
75-
return [$author->username => $author];
76+
return [strtolower($author->username) => $author];
7677
});
7778
}
7879

0 commit comments

Comments
 (0)