Skip to content

Commit

Permalink
FileUpload::getSanitizedName: Remove redundant minus before dot. (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek authored May 14, 2020
1 parent e944078 commit c9fc147
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Http/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getName(): string
*/
public function getSanitizedName(): string
{
return trim(Nette\Utils\Strings::webalize($this->name, '.', false), '.-');
return trim(str_replace('-.', '.', Nette\Utils\Strings::webalize($this->name, '.', false)), '.-');
}


Expand Down
13 changes: 13 additions & 0 deletions tests/Http/FileUpload.basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ test(function () {
});


test(function () {
$upload = new FileUpload([
'name' => 'logo 2020+.pdf',
'type' => 'text/plain',
'tmp_name' => __DIR__ . '/files/logo.png',
'error' => 0,
'size' => 209,
]);

Assert::same('logo-2020.pdf', $upload->getSanitizedName());
});


test(function () {
$upload = new FileUpload([
'name' => '',
Expand Down

0 comments on commit c9fc147

Please sign in to comment.