diff --git a/app/src/main/kotlin/com/svenjacobs/app/leon/startup/ContainerInitializer.kt b/app/src/main/kotlin/com/svenjacobs/app/leon/startup/ContainerInitializer.kt index 8252c811..f2e308ea 100644 --- a/app/src/main/kotlin/com/svenjacobs/app/leon/startup/ContainerInitializer.kt +++ b/app/src/main/kotlin/com/svenjacobs/app/leon/startup/ContainerInitializer.kt @@ -38,6 +38,7 @@ import com.svenjacobs.app.leon.core.domain.sanitizer.georiot.GeoRiotSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.google.GoogleAdsSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.google.GoogleAnalyticsSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.google.GoogleSearchSanitizer +import com.svenjacobs.app.leon.core.domain.sanitizer.google.GoogleStoreSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.heise.HeiseSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.instagram.InstagramSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.jdoqocy.JdoqocySanitizer @@ -93,6 +94,7 @@ class ContainerInitializer : DistinctInitializer { GoogleAdsSanitizer(), GoogleAnalyticsSanitizer(), GoogleSearchSanitizer(), + GoogleStoreSanitizer(), HeiseSanitizer(), InstagramSanitizer(), JdoqocySanitizer(), diff --git a/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/google/GoogleStoreSanitizer.kt b/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/google/GoogleStoreSanitizer.kt new file mode 100644 index 00000000..9708a5fa --- /dev/null +++ b/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/google/GoogleStoreSanitizer.kt @@ -0,0 +1,41 @@ +/* + * Léon - The URL Cleaner + * Copyright (C) 2023 Sven Jacobs + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.svenjacobs.app.leon.core.domain.sanitizer.google + +import android.content.Context +import com.svenjacobs.app.leon.core.common.domain.matchesDomain +import com.svenjacobs.app.leon.core.common.regex.RegexFactory +import com.svenjacobs.app.leon.core.domain.R +import com.svenjacobs.app.leon.core.domain.sanitizer.RegexSanitizer +import com.svenjacobs.app.leon.core.domain.sanitizer.Sanitizer +import com.svenjacobs.app.leon.core.domain.sanitizer.SanitizerId + +class GoogleStoreSanitizer : + RegexSanitizer( + RegexFactory.ofParameter("hl|selections"), + ) { + + override val id = SanitizerId("google_play_store") + + override fun getMetadata(context: Context) = Sanitizer.Metadata( + name = context.getString(R.string.sanitizer_google_play_store_name), + ) + + override fun matchesDomain(input: String) = input.matchesDomain("store.google.com") +} diff --git a/core-domain/src/main/res/values/strings.xml b/core-domain/src/main/res/values/strings.xml index 8f2dd20c..38279905 100644 --- a/core-domain/src/main/res/values/strings.xml +++ b/core-domain/src/main/res/values/strings.xml @@ -34,6 +34,7 @@ Google Analytics GeoRiot Google Ads + Google Play Store Google Search heise online Instagram diff --git a/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/google/GoogleStoreSanitizerTest.kt b/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/google/GoogleStoreSanitizerTest.kt new file mode 100644 index 00000000..26c4d7bb --- /dev/null +++ b/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/google/GoogleStoreSanitizerTest.kt @@ -0,0 +1,44 @@ +/* + * Léon - The URL Cleaner + * Copyright (C) 2023 Sven Jacobs + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.svenjacobs.app.leon.core.domain.sanitizer.google + +import io.kotest.core.spec.style.WordSpec +import io.kotest.matchers.shouldBe + +class GoogleStoreSanitizerTest : + WordSpec( + { + + val sanitizer = GoogleStoreSanitizer() + + "invoke" should { + + "remove \"hl\" and \"selections\" parameters" { + val result = sanitizer( + "https://store.google.com/gb/product/chromecast_google_tv?hl=en-GB" + + "&selections=eyJwcm9kdWN0RmFtaWx5IjoiWTJoeWIyMWxZMkZ6ZEY5bmIyOW5iR1" + + "ZmZEhZPSIsImhlcm9Qcm9kdWN0cyI6W1siY0hKa1h6YzRNekpmTXprMU1nPT0iLDEs" + + "bnVsbF1dfQ%3D%3D", + ) + + result shouldBe "https://store.google.com/gb/product/chromecast_google_tv" + } + } + }, + )