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 1e846b81..dc4b9432 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.heise.HeiseSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.instagram.InstagramSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.jdoqocy.JdoqocySanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.lazada.LazadaSanitizer @@ -90,6 +91,7 @@ class ContainerInitializer : DistinctInitializer { GoogleAdsSanitizer(), GoogleAnalyticsSanitizer(), GoogleSearchSanitizer(), + HeiseSanitizer(), InstagramSanitizer(), JdoqocySanitizer(), LazadaSanitizer(), diff --git a/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/heise/HeiseSanitizer.kt b/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/heise/HeiseSanitizer.kt new file mode 100644 index 00000000..da8f9624 --- /dev/null +++ b/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/heise/HeiseSanitizer.kt @@ -0,0 +1,39 @@ +/* + * 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.heise + +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 HeiseSanitizer : RegexSanitizer( + RegexFactory.AllParameters, +) { + override val id = SanitizerId("heise") + + override fun getMetadata(context: Context) = Sanitizer.Metadata( + name = context.getString(R.string.sanitizer_heise), + ) + + override fun matchesDomain(input: String) = input.matchesDomain("heise.de") +} diff --git a/core-domain/src/main/res/values/strings.xml b/core-domain/src/main/res/values/strings.xml index ed369e7e..a5ad98d3 100644 --- a/core-domain/src/main/res/values/strings.xml +++ b/core-domain/src/main/res/values/strings.xml @@ -35,6 +35,7 @@ GeoRiot Google Ads Google Search + heise online Instagram Jdoqocy Lazada diff --git a/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/heise/HeiseSanitizerTest.kt b/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/heise/HeiseSanitizerTest.kt new file mode 100644 index 00000000..62a5c7ac --- /dev/null +++ b/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/heise/HeiseSanitizerTest.kt @@ -0,0 +1,46 @@ +/* + * 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.heise + +import io.kotest.core.spec.style.WordSpec +import io.kotest.matchers.shouldBe + +class HeiseSanitizerTest : WordSpec( + { + val sanitizer = HeiseSanitizer() + + "invoke" should { + + "clean heise.de URLs" { + sanitizer.invoke( + "https://www.heise.de/news/Boom-bei-Balkonkraftwerken-Bereits-mehr-als-" + + "300-000-in-Betrieb-9324094.html?wt_mc=rss.red.ho.ho.rdf.beitrag.beitrag", + ) shouldBe "https://www.heise.de/news/Boom-bei-Balkonkraftwerken-Bereits-mehr-als" + + "-300-000-in-Betrieb-9324094.html" + } + } + + "matchesDomain" should { + + "match heise.de" { + sanitizer.matchesDomain("https://heise.de") shouldBe true + } + } + }, +)