Skip to content

Commit 43f4146

Browse files
author
SmetDenis
committed
fix isAbsolute for windows fs paths
1 parent b5e2b8c commit 43f4146

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Url.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ public static function pathToUrl($path)
521521
*/
522522
public static function isAbsolute($path)
523523
{
524-
$result = preg_match('#^(?:[a-z-]+:|\/\/)#i', $path);
524+
$result = strpos($path, '//') === 0
525+
|| preg_match('#^[a-z-]{3,}:\/\/#i', $path);
525526

526527
return $result;
527528
}

tests/UrlTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,12 @@ public function testIsAbsolute()
172172
isTrue(Url::isAbsolute('https://site.com'));
173173
isTrue(Url::isAbsolute('http://site.com'));
174174
isTrue(Url::isAbsolute('//site.com'));
175+
isTrue(Url::isAbsolute('ftp://site.com'));
176+
175177
isFalse(Url::isAbsolute('/path/to/file'));
178+
isFalse(Url::isAbsolute('w:/path/to/file'));
179+
isFalse(Url::isAbsolute('W:/path/to/file'));
180+
isFalse(Url::isAbsolute('W:\path\to\file'));
176181
}
177182

178183
public function testEmpty()

0 commit comments

Comments
 (0)