Skip to content

Commit

Permalink
Merge pull request #1237 from hydephp/bugfixes
Browse files Browse the repository at this point in the history
Normalize internal author array keys to lowercase to make author usernames case-insensitive
  • Loading branch information
caendesilva authored Mar 8, 2023
2 parents 260fc53 + d12f0e9 commit 03d3235
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Hyde\Facades\Author;
use Hyde\Facades\Config;
use Illuminate\Support\Collection;
use function strtolower;
use function is_string;

/**
Expand Down Expand Up @@ -65,14 +66,14 @@ public static function getOrCreate(string|array $data): static
/** Get an Author from the config, or create it. */
public static function get(string $username): static
{
return static::all()->firstWhere('username', $username) ?? Author::create($username);
return static::all()->firstWhere('username', strtolower($username)) ?? Author::create($username);
}

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

Expand Down

0 comments on commit 03d3235

Please sign in to comment.