Skip to content

Commit

Permalink
fixup! haha regexps
Browse files Browse the repository at this point in the history
  • Loading branch information
deadtrickster committed Sep 8, 2023
1 parent 9ec793c commit 9e40f92
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions deps/rabbitmq_stomp/src/rabbit_stomp_processor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1736,13 +1736,17 @@ parse_endpoint(undefined) ->
parse_endpoint(Destination) when is_binary(Destination) ->
parse_endpoint(unicode:characters_to_list(Destination));
parse_endpoint(Destination) when is_list(Destination) ->
case re:split(Destination, "/", [{return, list}]) of
case string:split(Destination, "/", all) of
[Name] ->
{ok, {queue, unescape(Name)}};
["", Type | Rest]
when Type =:= "exchange" orelse Type =:= "queue" orelse
Type =:= "topic" orelse Type =:= "temp-queue" ->
parse_endpoint0(atomise(Type), Rest);
["", "exchange" | Rest] ->
parse_endpoint0(exchange, Rest);
["", "queue" | Rest] ->
parse_endpoint0(queue, Rest);
["", "topic" | Rest] ->
parse_endpoint0(topic, Rest);
["", "temp-queue" | Rest] ->
parse_endpoint0(temp_queue, Rest);
["", "amq", "queue" | Rest] ->
parse_endpoint0(amqqueue, Rest);
["", "reply-queue" = Prefix | [_|_]] ->
Expand Down Expand Up @@ -1869,9 +1873,6 @@ new_amqqueue(QNameBin0, Type, Params0, _State = #proc_state{user = #user{usernam
to_url([]) -> [];
to_url(Lol) -> "/" ++ string:join(Lol, "/").

atomise(Name) when is_list(Name) ->
list_to_atom(re:replace(Name, "-", "_", [{return,list}, global])).

unescape(Str) -> unescape(Str, []).

unescape("%2F" ++ Str, Acc) -> unescape(Str, [$/ | Acc]);
Expand Down

0 comments on commit 9e40f92

Please sign in to comment.