Correct parsing of vhost
authorMatthew Sackman <matthew@lshift.net>
Mon Feb 01 13:15:25 2010 +0000 (2010-02-01)
changeset 318e9c4bd97ee6
parent 30 98dc3c909cb6
child 32 3ae77827f2eb
Correct parsing of vhost
src/rabbit_shovel_sup.erl
     1.1 --- a/src/rabbit_shovel_sup.erl	Mon Feb 01 13:06:01 2010 +0000
     1.2 +++ b/src/rabbit_shovel_sup.erl	Mon Feb 01 13:15:25 2010 +0000
     1.3 @@ -205,7 +205,7 @@
     1.4      parse_declaration({[{Method, []} | Rest], Acc}).
     1.5  
     1.6  parse_uri({[Uri | Uris], Acc}) ->
     1.7 -    case uri_parser:parse(Uri, [{host, undefined}, {path, "/"},
     1.8 +    case uri_parser:parse(Uri, [{host, undefined}, {path, undefined},
     1.9                                  {port, undefined}, {'query', []}]) of
    1.10          {error, Reason} ->
    1.11              fail({unable_to_parse_uri, Uri, Reason});
    1.12 @@ -228,8 +228,11 @@
    1.13  build_broker(ParsedUri) ->
    1.14      [Host, Port, Path] =
    1.15          [proplists:get_value(F, ParsedUri) || F <- [host, port, path]],
    1.16 -    Params = #amqp_params { host = Host, port = Port,
    1.17 -                            virtual_host = list_to_binary(Path) },
    1.18 +    VHost = case Path of
    1.19 +                undefined -> <<"/">>;
    1.20 +                [$/|Rest] -> list_to_binary(Rest)
    1.21 +            end,
    1.22 +    Params = #amqp_params { host = Host, port = Port, virtual_host = VHost },
    1.23      Params1 =
    1.24          case proplists:get_value(userinfo, ParsedUri) of
    1.25              [Username, Password | _ ] ->