Skip to content

Commit

Permalink
fix uriFromFile on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Feb 13, 2024
1 parent bf9a55d commit 9dace45
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions protocol/source/served/lsp/uri.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ private void assertEquals(T)(T a, T b)

DocumentUri uriFromFile(scope const(char)[] file)
{
import std.ascii : isUpper, toLower;
import std.uri : encodeComponent;

if ((!isAbsolute(file) && !file.startsWith("/"))
|| !file.length)
throw new Exception(text("Tried to pass relative path '", file, "' to uriFromFile"));
file = file.buildNormalizedPath();
version(Windows)
{
file = file.replace("\\", "/");
file = driveName(file).toLower() ~ stripDrive(file);
}
file = file.buildNormalizedPath().replace("\\", "/");
if (file.length >= 2 && file[0].isUpper && file[1] == ':')
file = file[0].toLower ~ file[1 .. $];
assert(file.length);
if (file.ptr[0] != '/')
file = '/' ~ file; // always triple slash at start but never quad slash
Expand Down

0 comments on commit 9dace45

Please sign in to comment.