add string encoding
This commit is contained in:
parent
99b6a046b4
commit
e4b9dc7b54
@ -15,4 +15,26 @@ defmodule SsbBfe do
|
||||
def hello do
|
||||
:world
|
||||
end
|
||||
|
||||
def encode(value) when is_bitstring(value) do
|
||||
cond do
|
||||
String.starts_with?(value, "@") ->
|
||||
SsbBfe.Encoder.encode_feed(value)
|
||||
|
||||
String.starts_with?(value, "%") ->
|
||||
SsbBfe.Encoder.encode_msg(value)
|
||||
|
||||
String.starts_with?(value, "&") ->
|
||||
SsbBfe.Encoder.encode_blob(value)
|
||||
|
||||
String.ends_with?(value, ".sig.ed25519") ->
|
||||
SsbBfe.Encoder.encode_sig(value)
|
||||
|
||||
String.ends_with?(value, [".box", ".box2"]) ->
|
||||
SsbBfe.Encoder.encode_box(value)
|
||||
|
||||
true ->
|
||||
SsbBfe.Encoder.encode_str(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
# might be good to use a multiclause function for the `encode` function
|
||||
# - use the `where` conditional guard with e.g. `is_number`
|
||||
# - use the `when` conditional guard with e.g. `is_number`
|
||||
|
||||
defmodule SsbBfe.Encoder do
|
||||
# Extract the base64 substring from a sigil-link and decode it.
|
||||
|
Loading…
x
Reference in New Issue
Block a user