Linkify.Parser.restore_stripped_symbols/3 must always return iodata
This commit is contained in:
parent
7005cda9e4
commit
c4b4cb95fb
1 changed files with 5 additions and 6 deletions
|
@ -175,7 +175,7 @@ defmodule Linkify.Parser do
|
|||
|
||||
url ->
|
||||
link = link_url(url, opts)
|
||||
restore_stripped_symbols(buffer, url, link, opts)
|
||||
restore_stripped_symbols(buffer, url, link)
|
||||
end
|
||||
else
|
||||
:nomatch
|
||||
|
@ -344,19 +344,18 @@ defmodule Linkify.Parser do
|
|||
{:cont, {buffer, user_acc}}
|
||||
|
||||
{link, user_acc} ->
|
||||
{:halt, {restore_stripped_symbols(buffer, str, link, opts), user_acc}}
|
||||
{:halt, {restore_stripped_symbols(buffer, str, link), user_acc}}
|
||||
|
||||
link ->
|
||||
{:halt, {restore_stripped_symbols(buffer, str, link, opts), user_acc}}
|
||||
{:halt, {restore_stripped_symbols(buffer, str, link), user_acc}}
|
||||
end
|
||||
end
|
||||
|
||||
defp restore_stripped_symbols(buffer, buffer, link, _), do: link
|
||||
defp restore_stripped_symbols(buffer, buffer, link), do: link
|
||||
|
||||
defp restore_stripped_symbols(buffer, stripped_buffer, link, opts) do
|
||||
defp restore_stripped_symbols(buffer, stripped_buffer, link) do
|
||||
buffer
|
||||
|> String.split(stripped_buffer)
|
||||
|> Enum.intersperse(link)
|
||||
|> if(opts[:iodata], do: &Enum.reject(&1, fn el -> el == "" end), else: &Enum.join(&1)).()
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue