From d5091c3175786e5bcb0449f26cafe1795fd5f5d9 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Mon, 30 Jul 2018 21:59:04 +0200 Subject: [PATCH] Allow additionnal schemes in the config --- config/config.exs | 2 ++ lib/pleroma/formatter.ex | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index 3a7301348..ef5bcd65c 100644 --- a/config/config.exs +++ b/config/config.exs @@ -16,6 +16,8 @@ config :pleroma, Pleroma.Upload, config :pleroma, :emoji, shortcode_globs: ["/emoji/custom/**/*.png"] +config :pleroma, :uri_schemes, additionnal_schemes: [] + # Configures the endpoint config :pleroma, Pleroma.Web.Endpoint, url: [host: "localhost"], diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index fe3da09ac..e15c08fd6 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -199,10 +199,14 @@ defmodule Pleroma.Formatter do @doc "changes scheme:... urls to html links" def add_links({subs, text}) do + additionnal_schemes = + Application.get_env(:pleroma, :uri_schemes, []) + |> Keyword.get(:additionnal_schemes, []) + links = text |> String.split([" ", "\t", "
"]) - |> Enum.filter(fn word -> String.starts_with?(word, @uri_schemes) end) + |> Enum.filter(fn word -> String.starts_with?(word, @uri_schemes ++ additionnal_schemes) end) |> Enum.filter(fn word -> Regex.match?(@link_regex, word) end) |> Enum.map(fn url -> {Ecto.UUID.generate(), url} end) |> Enum.sort_by(fn {_, url} -> -String.length(url) end) -- 2.45.2