Encode spaces in paths to %20 instead of + (#140)
parent
9e65cd4cf0
commit
47472252a7
|
@ -39,7 +39,7 @@ function pathToUri(string $filepath): string
|
||||||
if (substr($first, -1) !== ':') {
|
if (substr($first, -1) !== ':') {
|
||||||
$first = urlencode($first);
|
$first = urlencode($first);
|
||||||
}
|
}
|
||||||
$parts = array_map('urlencode', $parts);
|
$parts = array_map('rawurlencode', $parts);
|
||||||
array_unshift($parts, $first);
|
array_unshift($parts, $first);
|
||||||
$filepath = implode('/', $parts);
|
$filepath = implode('/', $parts);
|
||||||
return 'file:///' . $filepath;
|
return 'file:///' . $filepath;
|
||||||
|
|
|
@ -25,7 +25,7 @@ class FileUriTest extends TestCase
|
||||||
|
|
||||||
// special chars are escaped
|
// special chars are escaped
|
||||||
$uri = pathToUri('c:/path/to/file/dürüm döner.php');
|
$uri = pathToUri('c:/path/to/file/dürüm döner.php');
|
||||||
$this->assertEquals('file:///c:/path/to/file/d%C3%BCr%C3%BCm+d%C3%B6ner.php', $uri);
|
$this->assertEquals('file:///c:/path/to/file/d%C3%BCr%C3%BCm%20d%C3%B6ner.php', $uri);
|
||||||
|
|
||||||
//backslashes are transformed
|
//backslashes are transformed
|
||||||
$uri = pathToUri('c:\\foo\\bar.baz');
|
$uri = pathToUri('c:\\foo\\bar.baz');
|
||||||
|
|
Loading…
Reference in New Issue