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 84a280b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions protocol/source/served/lsp/uri.d
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ unittest

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;
import std.uri : decodeComponent;
string ret = uri.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 84a280b

Please sign in to comment.