@@ -239,10 +239,15 @@ defmodule Base do
239
239
@ doc """
240
240
Decodes a base 64 encoded string into a binary string.
241
241
242
+ Accepts `ignore: :whitespace` option which will ignore all the
243
+ whitespace characters in the input string.
244
+
242
245
## Examples
243
246
244
247
iex> Base.decode64("Zm9vYmFy")
245
248
{:ok, "foobar"}
249
+ iex> Base.decode64("Zm9vYmFy\\ n", ignore: :whitespace)
250
+ {:ok, "foobar"}
246
251
247
252
"""
248
253
@ spec decode64 ( binary ) :: { :ok , binary } | :error
@@ -256,13 +261,18 @@ defmodule Base do
256
261
@ doc """
257
262
Decodes a base 64 encoded string into a binary string.
258
263
264
+ Accepts `ignore: :whitespace` option which will ignore all the
265
+ whitespace characters in the input string.
266
+
259
267
An `ArgumentError` exception is raised if the padding is incorrect or
260
268
a non-alphabet character is present in the string.
261
269
262
270
## Examples
263
271
264
272
iex> Base.decode64!("Zm9vYmFy")
265
273
"foobar"
274
+ iex> Base.decode64!("Zm9vYmFy\\ n", ignore: :whitespace)
275
+ "foobar"
266
276
267
277
"""
268
278
@ spec decode64! ( binary ) :: binary
@@ -290,10 +300,15 @@ defmodule Base do
290
300
Decodes a base 64 encoded string with URL and filename safe alphabet
291
301
into a binary string.
292
302
303
+ Accepts `ignore: :whitespace` option which will ignore all the
304
+ whitespace characters in the input string.
305
+
293
306
## Examples
294
307
295
308
iex> Base.url_decode64("_3_-_A==")
296
309
{:ok, <<255, 127, 254, 252>>}
310
+ iex> Base.url_decode64("_3_-_A==\\ n", ignore: :whitespace)
311
+ {:ok, <<255, 127, 254, 252>>}
297
312
298
313
"""
299
314
@ spec url_decode64 ( binary ) :: { :ok , binary } | :error
@@ -308,13 +323,18 @@ defmodule Base do
308
323
Decodes a base 64 encoded string with URL and filename safe alphabet
309
324
into a binary string.
310
325
326
+ Accepts `ignore: :whitespace` option which will ignore all the
327
+ whitespace characters in the input string.
328
+
311
329
An `ArgumentError` exception is raised if the padding is incorrect or
312
330
a non-alphabet character is present in the string.
313
331
314
332
## Examples
315
333
316
334
iex> Base.url_decode64!("_3_-_A==")
317
335
<<255, 127, 254, 252>>
336
+ iex> Base.url_decode64!("_3_-_A==\\ n", ignore: :whitespace)
337
+ <<255, 127, 254, 252>>
318
338
319
339
"""
320
340
@ spec url_decode64! ( binary ) :: binary
0 commit comments