diff options
author | Loïc Hoguin <[email protected]> | 2019-12-19 17:29:06 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-12-19 17:29:06 +0100 |
commit | e6c6ded1cae77c6352077473b583488793f0edad (patch) | |
tree | 139225ab70616deac42c1bd454c66e4cc5c8d9c8 | |
parent | ec8564ba97a9ee8526a109f5799c77eed5b99f7b (diff) | |
download | cowlib-e6c6ded1cae77c6352077473b583488793f0edad.tar.gz cowlib-e6c6ded1cae77c6352077473b583488793f0edad.tar.bz2 cowlib-e6c6ded1cae77c6352077473b583488793f0edad.zip |
Accept iodata() when building links
-rw-r--r-- | src/cow_link.erl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cow_link.erl b/src/cow_link.erl index 3a9526c..6f40464 100644 --- a/src/cow_link.erl +++ b/src/cow_link.erl @@ -355,7 +355,11 @@ resolve_test_() -> %% Build a link header. --spec link([link()]) -> iodata(). +-spec link([#{ + target := binary(), + rel := binary(), + attributes := [{binary(), binary()}] +}]) -> iodata(). link(Links) -> lists:join(<<", ">>, [do_link(Link) || Link <- Links]). @@ -363,7 +367,7 @@ do_link(#{target := TargetURI, rel := Rel, attributes := Params}) -> [ $<, TargetURI, <<">" "; rel=\"">>, Rel, $", - [[<<"; ">>, Key, <<"=\"">>, escape(Value, <<>>), $"] + [[<<"; ">>, Key, <<"=\"">>, escape(iolist_to_binary(Value), <<>>), $"] || {Key, Value} <- Params] ]. |