logo

auto_linker

AutoLinker-shim, based on https://git.pleroma.social/pleroma/auto_linker git clone https://hacktivis.me/git/auto_linker.git
commit: c4b4cb95fbd8ddc60dc259015f3088d415553c03
parent 7005cda9e48b746b1ce2004fc921eb75fc8d9310
Author: Sergey Suprunenko <suprunenko.s@gmail.com>
Date:   Thu, 10 Sep 2020 20:15:49 +0200

Linkify.Parser.restore_stripped_symbols/3 must always return iodata

Diffstat:

Mlib/linkify/parser.ex11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/linkify/parser.ex b/lib/linkify/parser.ex @@ -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