Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Replace oauth_params:explode with call to string:tokens.
  • Loading branch information
Tim Fletcher committed Aug 24, 2008
1 parent 93cd16b commit eb8367716f98699ddf0e0ea97b6815c04f14cb61
Showing 1 changed file with 1 addition and 11 deletions.
@@ -18,23 +18,13 @@ to_header_string({K,V}) ->
fmt:sprintf("%s=\"%s\"", [fmt:percent_encode(K), fmt:percent_encode(V)]).

from_string(Data) ->
map(fun param_from_string/1, explode($&, Data)).
map(fun param_from_string/1, string:tokens(Data, "&")).

param_from_string(Data) when is_list(Data) ->
param_from_string(break_at($=, Data));
param_from_string({K, V}) ->
{list_to_atom(oauth_util:percent_decode(K)), oauth_util:percent_decode(V)}.

explode(_Sep, []) ->
[];
explode(Sep, Chars) ->
explode(Sep, break_at(Sep, Chars), []).

explode(_Sep, {Param, []}, Params) ->
lists:reverse([Param|Params]);
explode(Sep, {Param, Etc}, Params) ->
explode(Sep, break_at(Sep, Etc), [Param|Params]).

break_at(Sep, Chars) ->
case lists:splitwith(fun(C) -> C =/= Sep end, Chars) of
Result={_, []} ->

0 comments on commit eb83677

Please sign in to comment.