diff --git a/lib/dotcom/content_rewriters/links.ex b/lib/dotcom/content_rewriters/links.ex index 481068fa03..339ec4b641 100644 --- a/lib/dotcom/content_rewriters/links.ex +++ b/lib/dotcom/content_rewriters/links.ex @@ -46,9 +46,15 @@ defmodule Dotcom.ContentRewriters.Links do """ def add_locale_params({"a", attrs, children} = element, %{cookies: %{"googtrans" => languages}}) do attr_map = Enum.into(attrs, %{}) - href = Map.get(attr_map, "href", "") locale = String.split(languages, "/") |> List.last() + href = + case Map.get(attr_map, "href") do + href when is_binary(href) -> href + [href] -> href + _ -> "" + end + if String.match?(href, ~r/mycharlie.mbta.com/) do updated_href = "#{href}?locale=#{locale}" updated_attrs = attr_map |> Map.replace!("href", updated_href) |> Map.to_list()