File tree 1 file changed +8
-9
lines changed
protocol/source/served/lsp
1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -14,22 +14,21 @@ private void assertEquals(T)(T a, T b)
14
14
15
15
DocumentUri uriFromFile (scope const (char )[] file)
16
16
{
17
+ import std.ascii : isAlpha, toLower;
17
18
import std.uri : encodeComponent;
18
19
19
20
if ((! isAbsolute(file) && ! file.startsWith(" /" ))
20
21
|| ! file.length)
21
22
throw new Exception (text(" Tried to pass relative path '" , file, " ' to uriFromFile" ));
22
- file = file.buildNormalizedPath();
23
- version (Windows )
24
- {
25
- file = file.replace(" \\ " , " /" );
26
- file = driveName(file).toLower() ~ stripDrive(file);
27
- }
23
+ file = file.buildNormalizedPath().replace(" \\ " , " /" );
28
24
assert (file.length);
29
- if (file.ptr [0 ] != ' / ' )
30
- file = ' / ' ~ file; // always triple slash at start but never quad slash
31
- if (file.length >= 2 && file[0 .. 2 ] == " //" ) // Shares (\\share\bob) are different somehow
25
+ if (file.length >= 2 && file [0 ].isAlpha && file[ 1 ] == ' : ' )
26
+ file = file[ 0 ].toLower ~ file[ 1 .. $];
27
+ else if (file.length >= 2 && file[0 .. 2 ] == " //" ) // Shares (\\share\bob) are different somehow
32
28
file = file[2 .. $];
29
+ else if (file.ptr[0 ] != ' /' )
30
+ file = ' /' ~ file; // always triple slash at start but never quad slash
31
+
33
32
return text (" file://" , file.encodeComponent.replace(" %2F" , " /" ));
34
33
}
35
34
You can’t perform that action at this time.
0 commit comments