Skip to content

Commit

Permalink
opt for using String functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jalcine committed Nov 20, 2019
1 parent 54aa24b commit e414c7f
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/tesla/middleware/decode_rels.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,8 @@ defmodule Tesla.Middleware.DecodeRels do
end

defp rel(item) do
case Regex.run(~r/\A<(.+)>; rel=['"]?(.+)['"]?\z/, item, capture: :all_but_first) do
nil ->
%{}

link_rel ->
link_rel
|> Enum.reverse()
|> List.replace_at(0, String.trim(List.last(link_rel), "\""))
|> List.to_tuple()
end
[url, param] = String.split(item, ";")
[_attr, value] = param |> String.trim() |> String.split("=")
{value |> String.trim("'") |> String.trim("\""), url |> String.trim(">") |> String.trim("<")}
end
end

0 comments on commit e414c7f

Please sign in to comment.