From 5aba4a3666a071b40e335097466fba3710ed1d61 Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Fri, 26 Jan 2024 11:42:22 -0500 Subject: [PATCH] Add a helper function to convert from url to siteMonitor type --- .../android/ui/sitemonitor/SiteMonitorUtils.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorUtils.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorUtils.kt index 891931689048..dbaa7b25cebd 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorUtils.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitemonitor/SiteMonitorUtils.kt @@ -25,7 +25,17 @@ class SiteMonitorUtils @Inject constructor( fun sanitizeSiteUrl(url: String?) = url?.replace(Regex(HTTP_PATTERN), "") ?: "" + fun urlToType(url: String): SiteMonitorType { + return when { + url.contains(PHP_LOGS_PATTERN) -> SiteMonitorType.PHP_LOGS + url.contains(WEB_SERVER_LOGS_PATTERN) -> SiteMonitorType.WEB_SERVER_LOGS + else -> SiteMonitorType.METRICS + } + } + companion object { const val HTTP_PATTERN = "(https?://)" + const val PHP_LOGS_PATTERN = "/php" + const val WEB_SERVER_LOGS_PATTERN = "/web" } }