mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
[fenix] Switch to any calls
This commit is contained in:
parent
f627bb78ec
commit
3207a9d1a2
@ -82,14 +82,8 @@ abstract class BaseSearchTelemetry {
|
||||
|
||||
abstract fun install(engine: Engine, store: BrowserStore)
|
||||
|
||||
internal fun getProviderForUrl(url: String): SearchProviderModel? {
|
||||
for (provider in providerList) {
|
||||
if (Regex(provider.regexp).containsMatchIn(url)) {
|
||||
return provider
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
internal fun getProviderForUrl(url: String): SearchProviderModel? =
|
||||
providerList.find { provider -> provider.regexp.containsMatchIn(url) }
|
||||
|
||||
internal fun installWebExtension(
|
||||
engine: Engine,
|
||||
|
@ -39,23 +39,8 @@ data class SearchProviderModel(
|
||||
* Checks if any of the given URLs represent an ad from the search engine.
|
||||
* Used to check if a clicked link was for an ad.
|
||||
*/
|
||||
fun containsAds(urlList: List<String>) = urlList.containsAds(extraAdServersRegexps)
|
||||
fun containsAds(urlList: List<String>) = urlList.any { url -> isAd(url) }
|
||||
|
||||
private fun String.isAd(adRegexps: List<Regex>): Boolean {
|
||||
for (adsRegex in adRegexps) {
|
||||
if (adsRegex.containsMatchIn(this)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun List<String>.containsAds(adRegexps: List<Regex>): Boolean {
|
||||
for (url in this) {
|
||||
if (url.isAd(adRegexps)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
private fun isAd(url: String) =
|
||||
extraAdServersRegexps.any { adsRegex -> adsRegex.containsMatchIn(url) }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user