aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.erl
diff options
context:
space:
mode:
authorPeter Saxton <peterhsaxton@gmail.com>2020-06-23 11:09:01 +0100
committerLouis Pilfold <louis@lpil.uk>2020-06-24 22:09:19 +0100
commit5077a4915893310e2f94a6541563529305e3cd28 (patch)
tree1f2ce90ba1219f858e0d55e20dec0d979b372df3 /src/gleam_stdlib.erl
parent5017b8bff3097206d36bc6d5f28ce082649d4dbc (diff)
downloadgleam_stdlib-5077a4915893310e2f94a6541563529305e3cd28.tar.gz
gleam_stdlib-5077a4915893310e2f94a6541563529305e3cd28.zip
encode and decode functions for bas64
Diffstat (limited to 'src/gleam_stdlib.erl')
-rw-r--r--src/gleam_stdlib.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index f0adbd0..47fbdb5 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -11,7 +11,7 @@
string_pad/4, decode_tuple2/1, decode_map/1, bit_string_int_to_u32/1,
bit_string_int_from_u32/1, bit_string_append/2, bit_string_part_/3,
decode_bit_string/1, regex_from_string/1, regex_from_string_with/2,
- regex_match/2]).
+ regex_match/2, base_decoded4/1]).
should_equal(Actual, Expected) -> ?assertEqual(Expected, Actual).
should_not_equal(Actual, Expected) -> ?assertNotEqual(Expected, Actual).
@@ -189,3 +189,8 @@ regex_match(Regex, String) ->
{match, _} -> true;
_ -> false
end.
+
+base_decoded4(S) ->
+ try {ok, base64:decode(S)} catch
+ error:badarith -> {error, nil}
+ end.