parse_url returns false for malformed urls, not null
parent
18c6ccd137
commit
daaf1f2980
|
@ -38,7 +38,7 @@ function pathToUri(string $filepath): string
|
||||||
function uriToPath(string $uri)
|
function uriToPath(string $uri)
|
||||||
{
|
{
|
||||||
$fragments = parse_url($uri);
|
$fragments = parse_url($uri);
|
||||||
if ($fragments === null || !isset($fragments['scheme']) || $fragments['scheme'] !== 'file') {
|
if ($fragments === false || !isset($fragments['scheme']) || $fragments['scheme'] !== 'file') {
|
||||||
throw new InvalidArgumentException("Not a valid file URI: $uri");
|
throw new InvalidArgumentException("Not a valid file URI: $uri");
|
||||||
}
|
}
|
||||||
$filepath = urldecode($fragments['path']);
|
$filepath = urldecode($fragments['path']);
|
||||||
|
|
Loading…
Reference in New Issue