# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MediaProxy.Invalidation.Script do
def purge(urls, opts \\ []) do
args =
urls
+ |> maybe_format_urls(Keyword.get(opts, :url_format))
|> List.wrap()
|> Enum.uniq()
|> Enum.join(" ")
Logger.error("Error while cache purge: #{inspect(error)}")
{:error, inspect(error)}
end
+
+ def maybe_format_urls(urls, :htcacheclean) do
+ urls
+ |> Enum.map(fn url ->
+ uri = URI.parse(url)
+
+ query =
+ if !is_nil(uri.query) do
+ "?" <> uri.query
+ else
+ "?"
+ end
+
+ uri.scheme <> "://" <> uri.host <> ":#{inspect(uri.port)}" <> uri.path <> query
+ end)
+ end
+
+ def maybe_format_urls(urls, _), do: urls
end