Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug in filename slug when file extension is uppercase #39

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Helpers/FileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function slug($name)

$name = Str::slug($name);

return $name . $extension;
return $name . strtolower($extension);
}

/**
Expand All @@ -21,6 +21,6 @@ public static function slug($name)
*/
private static function getExtension($name)
{
return strtolower(substr($name, strrpos($name, '.')));
return substr($name, strrpos($name, '.'));
}
}
9 changes: 9 additions & 0 deletions Tests/FileHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@ public function it_should_return_slugged_name_with_extension()

$this->assertEquals($expected, $name);
}

/** @test */
public function it_should_return_slugged_name_when_uppercase_extension_provided()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method name FileHelperTest::it_should_return_slugged_name_when_uppercase_extension_provided is not in camel caps format

{
$expected = 'file-name.png';
$name = FileHelper::slug('File Name.PNG');

$this->assertEquals($expected, $name);
}
}