@@ -8,21 +8,27 @@ import com.wstxda.clippy.cleaner.providers.UrlSchemeProvider
88import kotlinx.coroutines.Dispatchers
99import kotlinx.coroutines.withContext
1010import androidx.core.net.toUri
11+ import android.util.Log
12+ import com.wstxda.clippy.utils.Constants
1113
1214object UrlCleaner {
13- private val applyCleaningModules =
14- listOf< suspend (String ) -> String > (
15- { url -> RedirectionHandler .resolveRedirectionParams(url) },
16- { url -> TrackerRemover .removeTrackersParams(url) },
17- { url -> ShortenerRemover .removeShortenerParams(url) },
18- { url -> BuiltinRulesResolver .applyBuiltinRules(url) })
15+ private val applyCleaningModules = listOf< suspend (String ) -> String > (
16+ { url -> RedirectionHandler .resolveRedirectionParams(url) },
17+ { url -> TrackerRemover .removeTrackersParams(url) },
18+ { url -> ShortenerRemover .removeShortenerParams(url) },
19+ { url -> BuiltinRulesResolver .applyBuiltinRules(url) })
1920
2021 suspend fun startUrlCleanerModules (url : String ): String = withContext(Dispatchers .IO ) {
2122 val uri = url.toUri()
2223 val scheme = uri.scheme
2324 if (scheme != null && UrlSchemeProvider .needsCleaning(scheme)) {
2425 applyCleaningModules.fold(url) { currentUrl, cleaner ->
25- cleaner(currentUrl)
26+ try {
27+ cleaner(currentUrl)
28+ } catch (e: Exception ) {
29+ Log .e(Constants .URL_CLEANER , " Error applying cleaner module to URL: ${e.message} " , e)
30+ currentUrl
31+ }
2632 }
2733 } else {
2834 url
0 commit comments