Skip to content

Commit

Permalink
Revert "fix parsing URLs with query string after the domain name"
Browse files Browse the repository at this point in the history
This reverts commit d24a194.
  • Loading branch information
benoitc committed Nov 3, 2015
1 parent 4a768ff commit 38b6970
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
2 changes: 1 addition & 1 deletion THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Richard Jones <rj@metabrew.com>
Eduardo Gurgel <eduardo@gurgel.me>
Mayorov Andrey <avmayorov@platbox.com>
omarkj <omarkj@gmail.com>
Pavel Abalikhin <anpavl@gmail.com>
Pavel Abalihin <anpavl@gmail.com>
Ilya Khaprov <dead.trickster@gmail.com>
25 changes: 9 additions & 16 deletions src/http/hackney_url.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,16 @@ parse_url(URL) ->
parse_url(URL, #hackney_url{transport=hackney_tcp_transport,
scheme=http}).
parse_url(URL, S) ->
{Addr, RawPath} =
case binary:split(URL, <<"/">>) of
[Addr1] ->
case binary:split(Addr1, <<"?">>) of
[_] -> {Addr1, <<"/">>};
[Addr2, Query1] -> {Addr2, <<"/?", Query1/binary>>}
end;
[Addr1, Path1] -> {Addr1, <<"/", Path1/binary>>}
end,
case RawPath of
<<"/">> ->
parse_addr(Addr, S#hackney_url{raw_path = RawPath,
path = RawPath });
_ ->
{Path, Query, Fragment} = parse_path(RawPath),
case binary:split(URL, <<"/">>) of
[Addr] ->
Path = <<"/">>,
parse_addr(Addr, S#hackney_url{raw_path = Path,
path = Path });
[Addr, Path] ->
RawPath = <<"/", Path/binary>>,
{Path1, Query, Fragment} = parse_path(RawPath),
parse_addr(Addr, S#hackney_url{raw_path = RawPath,
path = Path,
path = Path1,
qs = Query,
fragment = Fragment})
end.
Expand Down
13 changes: 0 additions & 13 deletions test/hackney_url_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,6 @@ parse_url_test_() ->
user = <<"">>,
password = <<"">>}
},
{<<"www.example.com?key=value#Section%205">>,
#hackney_url{transport =hackney_tcp_transport,
scheme = http,
netloc = <<"www.example.com">>,
raw_path = <<"/?key=value#Section%205">>,
path = <<"/">>,
qs = <<"key=value">>,
fragment = <<"Section%205">>,
host = "www.example.com",
port = 80,
user = <<"">>,
password = <<"">>}
},
{<<"http://www.example.com">>,
#hackney_url{transport =hackney_tcp_transport,
scheme = http,
Expand Down

0 comments on commit 38b6970

Please sign in to comment.