Skip to content

Commit

Permalink
Add a helper function to convert from url to siteMonitor type
Browse files Browse the repository at this point in the history
  • Loading branch information
zwarm committed Jan 26, 2024
1 parent 5a2f30f commit 5aba4a3
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 5aba4a3

Please sign in to comment.