From 7b1bd5d0d1f3a93c1c6d09df9cdc61e1af7c4940 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Wed, 8 May 2024 16:52:15 -0500 Subject: [PATCH] check path as well as host (#2043) --- lib/cms/api.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/cms/api.ex b/lib/cms/api.ex index 5af6674e18..05d4df7e8e 100644 --- a/lib/cms/api.ex +++ b/lib/cms/api.ex @@ -79,7 +79,14 @@ defmodule CMS.Api do end defp set_redirect_options(uri) do - [external: parse_redirect_query(uri)] + base_url = Application.get_env(:dotcom, :cms_api)[:base_url] + file_path = "/sites/default/files" + + if String.contains?(base_url, uri.host) and not String.contains?(uri.path, file_path) do + [to: uri |> internal_uri() |> parse_redirect_query()] + else + [external: parse_redirect_query(uri)] + end end @spec parse_redirect_query(URI.t()) :: String.t()