diff --git a/src/Modifiers/CoreModifiers.php b/src/Modifiers/CoreModifiers.php index 15c2623de8..23b731b15e 100644 --- a/src/Modifiers/CoreModifiers.php +++ b/src/Modifiers/CoreModifiers.php @@ -1032,7 +1032,7 @@ public function isUppercase($value) */ public function isUrl($value) { - return filter_var($value, FILTER_VALIDATE_URL) !== false; + return Str::isUrl($value); } /** diff --git a/src/Support/Str.php b/src/Support/Str.php index ebd68f274a..94378f2eca 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -115,7 +115,7 @@ public static function slugToTitle($string) public static function isUrl($string) { - return self::startsWith($string, ['http://', 'https://', '/']); + return self::startsWith($string, '/') || filter_var($string, FILTER_VALIDATE_URL) !== false; } public static function deslugify($string) diff --git a/tests/Support/StrTest.php b/tests/Support/StrTest.php index 0bf5d417b0..939c63f8c6 100644 --- a/tests/Support/StrTest.php +++ b/tests/Support/StrTest.php @@ -74,6 +74,8 @@ public function it_checks_for_a_url() { $this->assertTrue(Str::isUrl('http://example.com')); $this->assertTrue(Str::isUrl('https://example.com')); + $this->assertTrue(Str::isUrl('ftp://example.com')); + $this->assertTrue(Str::isUrl('mailto:bob@down.com')); $this->assertTrue(Str::isUrl('/relative')); $this->assertFalse(Str::isUrl('test')); }