aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/mozilla/components
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-07-08 01:25:55 +0530
committerGitHub <noreply@github.com>2020-07-08 01:25:55 +0530
commit616992087846fe76555080baf131637924b67507 (patch)
tree3130913ac749c3d765af3a38aa13208fefbf6400 /app/src/main/java/mozilla/components
parent4657185dc6f161418ce7e8e4f9dd2976fc54427a (diff)
global: set an import order rule and reformat with it (#924)
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/mozilla/components')
-rw-r--r--app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixList.kt1
-rw-r--r--app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt2
-rw-r--r--app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt1
3 files changed, 4 insertions, 0 deletions
diff --git a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixList.kt b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixList.kt
index 6df3caca..0fb59002 100644
--- a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixList.kt
+++ b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixList.kt
@@ -31,6 +31,7 @@ class PublicSuffixList(
dispatcher: CoroutineDispatcher = Dispatchers.IO,
private val scope: CoroutineScope = CoroutineScope(dispatcher)
) {
+
private val data: PublicSuffixListData by lazy { PublicSuffixListLoader.load(context) }
/**
diff --git a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt
index 0cbf6945..778e9fee 100644
--- a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt
+++ b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt
@@ -17,6 +17,7 @@ internal class PublicSuffixListData(
private val rules: ByteArray,
private val exceptions: ByteArray
) {
+
private fun binarySearchRules(labels: List<ByteArray>, labelIndex: Int): String? {
return rules.binarySearch(labels, labelIndex)
}
@@ -147,6 +148,7 @@ internal class PublicSuffixListData(
}
companion object {
+
val WILDCARD_LABEL = byteArrayOf('*'.toByte())
val PREVAILING_RULE = listOf("*")
val EMPTY_RULE = listOf<String>()
diff --git a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt
index 88e82523..65caeae5 100644
--- a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt
+++ b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt
@@ -14,6 +14,7 @@ import java.io.IOException
private const val PUBLIC_SUFFIX_LIST_FILE = "publicsuffixes"
internal object PublicSuffixListLoader {
+
fun load(context: Context): PublicSuffixListData = context.assets.open(
PUBLIC_SUFFIX_LIST_FILE
).buffered().use { stream ->