mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
fix(gateway): parse push relay hosts as binaries (#2989)
This commit is contained in:
@@ -605,21 +605,18 @@ to_binary(_, Default) -> Default.
|
|||||||
|
|
||||||
-spec parse_host_list(binary()) -> [binary()].
|
-spec parse_host_list(binary()) -> [binary()].
|
||||||
parse_host_list(Bin) ->
|
parse_host_list(Bin) ->
|
||||||
parse_host_list(string:lexemes(binary_to_list(Bin), ", \t"), []).
|
[
|
||||||
|
lower_ascii(Host)
|
||||||
|
|| Host <- binary:split(Bin, [<<",">>, <<" ">>, <<"\t">>], [global, trim_all])
|
||||||
|
].
|
||||||
|
|
||||||
-spec parse_host_list([string()], [binary()]) -> [binary()].
|
-spec lower_ascii(binary()) -> binary().
|
||||||
parse_host_list([], Acc) ->
|
lower_ascii(Bin) ->
|
||||||
lists:reverse(Acc);
|
<<<<(lower_byte(Byte))>> || <<Byte>> <= Bin>>.
|
||||||
parse_host_list([Host | Rest], Acc) ->
|
|
||||||
parse_host_list(Rest, [list_to_binary(lower_string(Host)) | Acc]).
|
|
||||||
|
|
||||||
-spec lower_string(string()) -> string().
|
-spec lower_byte(byte()) -> byte().
|
||||||
lower_string(Value) ->
|
lower_byte(Byte) when Byte >= $A, Byte =< $Z -> Byte + 32;
|
||||||
[lower_char(Char) || Char <- Value].
|
lower_byte(Byte) -> Byte.
|
||||||
|
|
||||||
-spec lower_char(char()) -> char().
|
|
||||||
lower_char(Char) when Char >= $A, Char =< $Z -> Char + 32;
|
|
||||||
lower_char(Char) -> Char.
|
|
||||||
|
|
||||||
-spec parse_node_list(binary() | undefined) -> [node()].
|
-spec parse_node_list(binary() | undefined) -> [node()].
|
||||||
parse_node_list(undefined) ->
|
parse_node_list(undefined) ->
|
||||||
|
|||||||
Reference in New Issue
Block a user