UploadedMedia: Increase readability via ~s sigil
This commit is contained in:
parent
8f0f58e28b
commit
2148ef5e2f
|
@ -35,9 +35,9 @@ def call(%{request_path: <<"/", @path, "/", file::binary>>} = conn, opts) do
|
||||||
conn =
|
conn =
|
||||||
case fetch_query_params(conn) do
|
case fetch_query_params(conn) do
|
||||||
%{query_params: %{"name" => name}} = conn ->
|
%{query_params: %{"name" => name}} = conn ->
|
||||||
name = String.replace(name, "\"", "\\\"")
|
name = String.replace(name, ~s["], ~s[\\"])
|
||||||
|
|
||||||
put_resp_header(conn, "content-disposition", "inline; filename=\"#{name}\"")
|
put_resp_header(conn, "content-disposition", ~s[inline; filename="#{name}"])
|
||||||
|
|
||||||
conn ->
|
conn ->
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -33,11 +33,11 @@ test "does not send Content-Disposition header when name param is not set", %{
|
||||||
test "sends Content-Disposition header when name param is set", %{
|
test "sends Content-Disposition header when name param is set", %{
|
||||||
attachment_url: attachment_url
|
attachment_url: attachment_url
|
||||||
} do
|
} do
|
||||||
conn = get(build_conn(), attachment_url <> "?name=\"cofe\".gif")
|
conn = get(build_conn(), attachment_url <> ~s[?name="cofe".gif])
|
||||||
|
|
||||||
assert Enum.any?(
|
assert Enum.any?(
|
||||||
conn.resp_headers,
|
conn.resp_headers,
|
||||||
&(&1 == {"content-disposition", "inline; filename=\"\\\"cofe\\\".gif\""})
|
&(&1 == {"content-disposition", ~s[inline; filename="\\"cofe\\".gif"]})
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue