Skip to content

Commit fcdbf46

Browse files
committed
update file extension to lowercase for consistency
1 parent 13805d7 commit fcdbf46

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/Models/Media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function fileName(): Attribute
6969
return Attribute::make(
7070
set: function ($value) {
7171
$fileName = sha1($value.microtime());
72-
$ext = pathinfo($value, PATHINFO_EXTENSION);
72+
$ext = strtolower(pathinfo($value, PATHINFO_EXTENSION));
7373

7474
return "$fileName.$ext";
7575
},

tests/FileStorageTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function setUp(): void
3636

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

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

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

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

5859
Queue::assertPushedWithChain(OptimizeImage::class, [
5960
GeneratePreview::class,
@@ -66,7 +67,7 @@ public function testUpdateMedia(): void
6667
$originalMedia = Media::factory()->create([
6768
'model_type' => 'App/Models/User',
6869
'model_id' => 1,
69-
'file_name' => 'fake-file.jpg',
70+
'file_name' => 'fake-file.JPG',
7071
'type' => TestDocumentType::AVATAR,
7172
]);
7273

File renamed without changes.

0 commit comments

Comments
 (0)