Skip to content

Commit c9fc147

Browse files
authored
FileUpload::getSanitizedName: Remove redundant minus before dot. (#179)
1 parent e944078 commit c9fc147

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Http/FileUpload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getName(): string
7575
*/
7676
public function getSanitizedName(): string
7777
{
78-
return trim(Nette\Utils\Strings::webalize($this->name, '.', false), '.-');
78+
return trim(str_replace('-.', '.', Nette\Utils\Strings::webalize($this->name, '.', false)), '.-');
7979
}
8080

8181

tests/Http/FileUpload.basic.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ test(function () {
5151
});
5252

5353

54+
test(function () {
55+
$upload = new FileUpload([
56+
'name' => 'logo 2020+.pdf',
57+
'type' => 'text/plain',
58+
'tmp_name' => __DIR__ . '/files/logo.png',
59+
'error' => 0,
60+
'size' => 209,
61+
]);
62+
63+
Assert::same('logo-2020.pdf', $upload->getSanitizedName());
64+
});
65+
66+
5467
test(function () {
5568
$upload = new FileUpload([
5669
'name' => '',

0 commit comments

Comments
 (0)