Skip to content

Commit

Permalink
Refactor: move extract host into its own method to expand the extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
zwarm committed Jan 29, 2024
1 parent 3281830 commit e81dd06
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ class SiteMonitorLinkHandler
}

override fun buildNavigateAction(uri: UriWrapper): DeepLinkNavigator.NavigateAction {
val targetHost = uri.pathSegments[1]
val targetHost = extractHost(uri)
val site: SiteModel? = deepLinkUriUtils.hostToSite(targetHost)
val siteMonitorType = urlToType(uri.toString())
return DeepLinkNavigator.NavigateAction.OpenSiteMonitoringForSite(site, siteMonitorType)
}

private fun extractHost(uri: UriWrapper): String {
if (uri.pathSegments.size <= 1) return ""
return uri.pathSegments[1]
}

override fun stripUrl(uri: UriWrapper): String {
return buildString {
val offset = if (uri.host == SITE_MONITORING_PATH) {
Expand Down

0 comments on commit e81dd06

Please sign in to comment.