Skip to content

Commit

Permalink
Use skipOver in uriToFile
Browse files Browse the repository at this point in the history
  • Loading branch information
nordlow committed Nov 19, 2024
1 parent 0c7fe66 commit 66f9487
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions protocol/source/served/lsp/uri.d
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ string uriToFile(DocumentUri uri)
import std.uri : decodeComponent;
import std.string : startsWith;

if (uri.startsWith("file://"))
if (uri.skipOver("file://"))
{
string ret = uri["file://".length .. $].decodeComponent;
if (ret.length >= 3 && ret[0] == '/' && ret[2] == ':') // file:///x: windows path
return ret[1 .. $].replace("/", "\\");
else if (ret.length >= 1 && ret[0] != '/') // file://share windows path
Expand Down Expand Up @@ -283,7 +282,7 @@ unittest
{
assertEquals(uriNormalize(`b/../a.d`), `a.d`);
assertEquals(uriNormalize(`b/../../a.d`), `../a.d`);

foreach (prefix; ["file:///", "file://", "", "/", "//"])
{
assertEquals(uriNormalize(prefix ~ `foo/bar/./a.d`), prefix ~ `foo/bar/a.d`);
Expand Down

0 comments on commit 66f9487

Please sign in to comment.