diff --git a/feature/trip-planner/ui/src/androidMain/kotlin/HtmlText.kt b/feature/trip-planner/ui/src/androidMain/kotlin/xyz/ksharma/krail/trip/planner/ui/alerts/HtmlText.kt
similarity index 100%
rename from feature/trip-planner/ui/src/androidMain/kotlin/HtmlText.kt
rename to feature/trip-planner/ui/src/androidMain/kotlin/xyz/ksharma/krail/trip/planner/ui/alerts/HtmlText.kt
diff --git a/feature/trip-planner/ui/src/iosMain/kotlin/HtmlText.kt b/feature/trip-planner/ui/src/iosMain/kotlin/HtmlText.kt
deleted file mode 100644
index 06f39210..00000000
--- a/feature/trip-planner/ui/src/iosMain/kotlin/HtmlText.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-package xyz.ksharma.krail.trip.planner.ui.alerts
-
-import androidx.compose.foundation.clickable
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.graphics.Color
-import xyz.ksharma.krail.taj.components.Text
-
-@Composable
-actual fun HtmlText(
- text: String,
- modifier: Modifier,
- onClick: () -> Unit,
- color: Color,
- urlColor: Color,
-) {
- Text(text = replaceHtmlTags(text), modifier = Modifier.clickable { onClick() }, color = color)
-}
-
-// TODO - A workaround for iOS until https://issuetracker.google.com/issues/139326648 is fixed.
-private fun replaceHtmlTags(html: String): String {
- return html
- .replace("", "\n")
- .replace("", "\n")
- .replace("
", "\n")
- .replace(Regex(""), " ")
- .replace(" ", " ")
- .replace(Regex("<[^>]*>"), "") // Remove all other HTML tags
- .replace(Regex("\n{3,}"), "\n\n") // Replace multiple new lines with a single new line
-}
diff --git a/feature/trip-planner/ui/src/iosMain/kotlin/xyz/ksharma/krail/trip/planner/ui/alerts/HtmlText.kt b/feature/trip-planner/ui/src/iosMain/kotlin/xyz/ksharma/krail/trip/planner/ui/alerts/HtmlText.kt
new file mode 100644
index 00000000..5bae6b67
--- /dev/null
+++ b/feature/trip-planner/ui/src/iosMain/kotlin/xyz/ksharma/krail/trip/planner/ui/alerts/HtmlText.kt
@@ -0,0 +1,37 @@
+package xyz.ksharma.krail.trip.planner.ui.alerts
+
+import androidx.compose.foundation.clickable
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import xyz.ksharma.krail.taj.components.Text
+
+@Composable
+actual fun HtmlText(
+ text: String,
+ modifier: Modifier,
+ onClick: () -> Unit,
+ color: Color,
+ urlColor: Color,
+) {
+ Text(text = replaceHtmlTags(text), modifier = Modifier.clickable { onClick() }, color = color)
+}
+
+// TODO - A workaround for iOS until https://issuetracker.google.com/issues/139326648 is fixed.
+fun replaceHtmlTags(html: String): String {
+ return runCatching {
+ html
+ .replace("", "\n")
+ .replace("", "\n")
+ .replace("
", "\n")
+ .replace("", "")
+ .replace("Item 2"
+ val expected = "Item 1\nItem 2"
+ assertEquals(expected, replaceHtmlTags(input))
+ }
+
+ @Test
+ fun testReplaceHtmlTags_withUl() {
+ val input = ""
+ val expected = "Item 1"
+ assertEquals(expected, replaceHtmlTags(input))
+ }
+
+ @Test
+ fun testReplaceHtmlTags_withAnchor() {
+ val input = "Link"
+ val expected = "Link"
+ assertEquals(expected, replaceHtmlTags(input))
+ }
+
+ @Test
+ fun testReplaceHtmlTags_withNbsp() {
+ val input = "Hello World"
+ val expected = "Hello World"
+ assertEquals(expected, replaceHtmlTags(input))
+ }
+
+ @Test
+ fun testReplaceHtmlTags_withMultipleHtmlTags() {
+ val input = "Hello
Item 2"
+ val expected = "Hello\nItem 1\nItem 2"
+ assertEquals(expected, replaceHtmlTags(input))
+ }
+
+ @Test
+ fun testReplaceHtmlTags_withMultipleNewLines() {
+ val input = "Hello\n\n\nWorld"
+ val expected = "Hello\n\nWorld"
+ assertEquals(expected, replaceHtmlTags(input))
+ }
+
+ @Test
+ fun testReplaceHtmlTags_withComplexHtml() {
+ val input = "Hello
Link World"
+ val expected = "Hello\n Link World"
+ assertEquals(expected, replaceHtmlTags(input))
+ }
+}