diff --git a/protocol/source/served/lsp/uri.d b/protocol/source/served/lsp/uri.d index c2fa2348..4926dbf0 100644 --- a/protocol/source/served/lsp/uri.d +++ b/protocol/source/served/lsp/uri.d @@ -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