Skip to content

Commit

Permalink
update file extension to lowercase for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
imahmood committed Feb 24, 2024
1 parent 13805d7 commit fcdbf46
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function fileName(): Attribute
return Attribute::make(
set: function ($value) {
$fileName = sha1($value.microtime());
$ext = pathinfo($value, PATHINFO_EXTENSION);
$ext = strtolower(pathinfo($value, PATHINFO_EXTENSION));

return "$fileName.$ext";
},
Expand Down
5 changes: 3 additions & 2 deletions tests/FileStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function setUp(): void

$this->fileStorage = new FileStorage($config);

$path = __DIR__.'/TestSupport/assets/avatar.jpg';
$path = __DIR__.'/TestSupport/assets/avatar.JPG';
$this->testFile = UploadedFile::fake()->create($path, file_get_contents($path));

Queue::fake();
Expand All @@ -54,6 +54,7 @@ public function testCreateMedia(): void

$this->assertNull($media->preview);
$this->assertSame($media->type, TestDocumentType::AVATAR->value);
$this->assertSame('jpg', pathinfo($media->file_name, PATHINFO_EXTENSION));

Queue::assertPushedWithChain(OptimizeImage::class, [
GeneratePreview::class,
Expand All @@ -66,7 +67,7 @@ public function testUpdateMedia(): void
$originalMedia = Media::factory()->create([
'model_type' => 'App/Models/User',
'model_id' => 1,
'file_name' => 'fake-file.jpg',
'file_name' => 'fake-file.JPG',
'type' => TestDocumentType::AVATAR,
]);

Expand Down
File renamed without changes

0 comments on commit fcdbf46

Please sign in to comment.