Skip to content

Commit 290c896

Browse files
committed
Handle file:///C: URI
1 parent 9d8d47f commit 290c896

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ function ($matches) {
205205
// that is used as the regex. The 2 backslash are then the way to get 1 backslash
206206
// character into the character set "a forward slash or a backslash"
207207
if (isset($result['scheme']) && 'file' === $result['scheme'] && isset($result['path']) &&
208-
preg_match('/^(?<windows_path> [a-zA-Z]:[\/\\\\].*)$/x', $result['path'])) {
208+
preg_match('/^(?<windows_path> [a-zA-Z]:([\/\\\\].*)?)$/x', $result['path'])) {
209209
$result['path'] = '/'.$result['path'];
210210
$result['host'] = '';
211211
}

tests/Uri/ParseTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,18 @@ public function parseData(): array
250250
'fragment' => null,
251251
],
252252
],
253+
[
254+
'file:///C:',
255+
[
256+
'scheme' => 'file',
257+
'host' => '',
258+
'path' => '/C:',
259+
'port' => null,
260+
'user' => null,
261+
'query' => null,
262+
'fragment' => null,
263+
],
264+
],
253265
];
254266
}
255267
}

0 commit comments

Comments
 (0)