diff --git a/assets/ts/components/Alerts.tsx b/assets/ts/components/Alerts.tsx
index 316d601a93..1e9fd95eb5 100644
--- a/assets/ts/components/Alerts.tsx
+++ b/assets/ts/components/Alerts.tsx
@@ -91,7 +91,7 @@ const htmlInsertFormatting = (str: string): string => {
return str
.replace(/^(.*:)\s/, "$1\n")
.replace(/\n(.*:)\s/, "
$1\n")
- .replace(/\s*\n/g, "
");
+ .replace(/\s*\n/g, "
");
};
// Strips off trailing periods of URLs (i guess the regex above matches the period if the URL is at the end of the sentence.)
diff --git a/assets/ts/components/__tests__/__snapshots__/AlertsTest.tsx.snap b/assets/ts/components/__tests__/__snapshots__/AlertsTest.tsx.snap
index 6cadc04e53..b113d4c672 100644
--- a/assets/ts/components/__tests__/__snapshots__/AlertsTest.tsx.snap
+++ b/assets/ts/components/__tests__/__snapshots__/AlertsTest.tsx.snap
@@ -76,8 +76,8 @@ exports[`it renders 1`] = `
Affected direction:
Inbound
-
Affected stops:
Meridian St @ West Eagle St",
+ "__html": "Affected direction:
Inbound
+
Affected stops:
Meridian St @ West Eagle St",
}
}
/>
diff --git a/lib/dotcom_web/views/alert_view.ex b/lib/dotcom_web/views/alert_view.ex
index 7e2a2f8652..aa1ccf0870 100644
--- a/lib/dotcom_web/views/alert_view.ex
+++ b/lib/dotcom_web/views/alert_view.ex
@@ -179,8 +179,8 @@ defmodule DotcomWeb.AlertView do
# an initial header
|> String.replace(~r/^(.*:)(\r\n|\r|\n)/, "\\1\n")
# all other start with a line break
- |> String.replace(~r/\n(.*:)(\r\n|\r|\n)/, "
\\1\n")
- |> String.replace(~r/\s*\n/s, "
")
+ |> String.replace(~r/\n(.*:)(\r\n|\r|\n)/, "
\\1\n")
+ |> String.replace(~r/\s*\n/s, "
")
|> replace_urls_with_links
end
diff --git a/test/dotcom_web/views/alert_view_test.exs b/test/dotcom_web/views/alert_view_test.exs
index ee42524b84..a6a153b5d7 100644
--- a/test/dotcom_web/views/alert_view_test.exs
+++ b/test/dotcom_web/views/alert_view_test.exs
@@ -60,35 +60,35 @@ defmodule DotcomWeb.AlertViewTest do
end
test "replaces newlines with breaks" do
- expected = {:safe, "hi
there"}
+ expected = {:safe, "hi
there"}
actual = format_alert_description("hi\nthere")
assert expected == actual
end
test "combines multiple newlines" do
- expected = {:safe, "hi
there"}
+ expected = {:safe, "hi
there"}
actual = format_alert_description("hi\n\n\nthere")
assert expected == actual
end
test "combines multiple Windows newlines" do
- expected = {:safe, "hi
there"}
+ expected = {:safe, "hi
there"}
actual = format_alert_description("hi\r\n\r\nthere")
assert expected == actual
end
test "ifies a header" do
- expected = {:safe, "hi
Header:
7:30"}
+ expected = {:safe, "hi
Header:
7:30"}
actual = format_alert_description("hi\nHeader:\n7:30")
assert expected == actual
end
test "ifies a starting long header" do
- expected = {:safe, "Long Header:
7:30"}
+ expected = {:safe, "Long Header:
7:30"}
actual = format_alert_description("Long Header:\n7:30")
assert expected == actual