Skip to content

Commit

Permalink
Refactor logic to replace ampersand
Browse files Browse the repository at this point in the history
  • Loading branch information
joshnuss committed Jun 4, 2015
1 parent aae31e6 commit 9fa39fa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/xml_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ defmodule XmlBuilder do
string
|> String.replace(">", ">")
|> String.replace("<", "&lt;")
|> fn(s) -> Regex.replace(~r/&(?!lt;|gt;|quot;)/, s, "&amp;") end.()
|> replace_ampersand
end

defp replace_ampersand(string) do
Regex.replace(~r/&(?!lt;|gt;|quot;)/, string, "&amp;")
end
end

0 comments on commit 9fa39fa

Please sign in to comment.