Skip to content

Commit

Permalink
Merge pull request #600 from erlang-ls/uri-handling-bug
Browse files Browse the repository at this point in the history
[#593] Fix URI handling bug
  • Loading branch information
robertoaloi authored Mar 20, 2020
2 parents 30f2f88 + 017367d commit a24a29c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/els_uri.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ path(Uri) ->

case {is_windows(), is_local(Host)} of
{_, true} ->
string:slice(Path, 1);
Path;
{true, false} ->
<<"//", Host/binary, Path/binary>>;
{false, false} ->
Expand All @@ -52,7 +52,7 @@ uri(Path) ->
true -> els_utils:to_binary(string:replace(Path, "\\", "/"));
false -> Path
end,
<<"file:///", Path1/binary>>.
<<"file://", Path1/binary>>.

-spec is_windows() -> boolean().
is_windows() ->
Expand All @@ -61,4 +61,4 @@ is_windows() ->

-spec is_local(binary()) -> boolean().
is_local(Host) ->
Host =:= <<>> orelse Host =:= <<"localhost">>.
Host =:= <<>> orelse Host =:= <<"localhost">>.
6 changes: 3 additions & 3 deletions test/els_references_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ record(Config) ->
-spec purge_references(config()) -> ok.
purge_references(_Config) ->
els_db:clear_tables(),
Uri = <<"file:////tmp/foo.erl">>,
Uri = <<"file:///tmp/foo.erl">>,
Text0 = "-spec foo(integer()) -> ok.\nfoo(_X) -> ok.\nbar() -> foo(1).",
Text1 = "\n-spec foo(integer()) -> ok.\nfoo(_X)-> ok.\nbar() -> foo(1).",
Doc0 = els_dt_document:new(Uri, Text0),
Expand All @@ -236,7 +236,7 @@ purge_references(_Config) ->
?assertEqual({ok, [Doc0]}, els_dt_document:lookup(Uri)),
?assertEqual({ok, [#{ id => {foo, foo, 1}
, range => #{from => {3, 10}, to => {3, 13}}
, uri => <<"file:////tmp/foo.erl">>
, uri => <<"file:///tmp/foo.erl">>
}]}
, els_dt_references:find_all()
),
Expand All @@ -245,7 +245,7 @@ purge_references(_Config) ->
?assertEqual({ok, [Doc1]}, els_dt_document:lookup(Uri)),
?assertEqual({ok, [#{ id => {foo, foo, 1}
, range => #{from => {4, 10}, to => {4, 13}}
, uri => <<"file:////tmp/foo.erl">>
, uri => <<"file:///tmp/foo.erl">>
}]}
, els_dt_references:find_all()
),
Expand Down

0 comments on commit a24a29c

Please sign in to comment.