Skip to content

Commit 6c79213

Browse files
rabbit_guide:string/2: support binary prefixes
(cherry picked from commit de658de)
1 parent b35ac6e commit 6c79213

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/rabbit_guid.erl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,15 @@ gen_secure() ->
143143
%%
144144
%% employs base64url encoding, which is safer in more contexts than
145145
%% plain base64.
146-
string(G, Prefix) ->
147-
Prefix ++ "-" ++ rabbit_misc:base64url(G).
146+
147+
-spec string(guid() | string(), any()) -> string().
148+
149+
string(G, Prefix) when is_list(Prefix) ->
150+
Prefix ++ "-" ++ rabbit_misc:base64url(G);
151+
string(G, Prefix) when is_binary(Prefix) ->
152+
binary_to_list(Prefix) ++ "-" ++ rabbit_misc:base64url(G).
153+
154+
-spec binary(guid() | string(), any()) -> binary().
148155

149156
binary(G, Prefix) ->
150157
list_to_binary(string(G, Prefix)).

0 commit comments

Comments
 (0)