Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a70c74d

Browse files
author
Loduis Madariaga
committed
Fix Str::endsWith() with needles that start with space and numbers.
1 parent 0b5c8bf commit a70c74d

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

src/Illuminate/Support/Str.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static function endsWith($haystack, $needles)
5656
{
5757
foreach ((array) $needles as $needle)
5858
{
59-
if ($needle == substr($haystack, -strlen($needle))) return true;
59+
if ((string) $needle === substr($haystack, -strlen($needle))) return true;
6060
}
6161

6262
return false;

tests/Support/SupportStrTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function testEndsWith()
5858
$this->assertFalse(Str::endsWith('jason', 'no'));
5959
$this->assertFalse(Str::endsWith('jason', array('no')));
6060
$this->assertFalse(Str::endsWith('jason', ''));
61+
$this->assertFalse(Str::endsWith('7', ' 7'));
6162
}
6263

6364

0 commit comments

Comments
 (0)