Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add sanitizer for heise.de #290

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,6 +91,7 @@ class ContainerInitializer : DistinctInitializer<Unit> {
GoogleAdsSanitizer(),
GoogleAnalyticsSanitizer(),
GoogleSearchSanitizer(),
HeiseSanitizer(),
InstagramSanitizer(),
JdoqocySanitizer(),
LazadaSanitizer(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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")
}
1 change: 1 addition & 0 deletions core-domain/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<string name="sanitizer_georiot_name" translatable="false">GeoRiot</string>
<string name="sanitizer_google_ads_name" translatable="false">Google Ads</string>
<string name="sanitizer_google_search_name">Google Search</string>
<string name="sanitizer_heise" translatable="false">heise online</string>
<string name="sanitizer_instagram_name" translatable="false">Instagram</string>
<string name="sanitizer_jdoqocy_name" translatable="false">Jdoqocy</string>
<string name="sanitizer_lazada" translatable="false">Lazada</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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
}
}
},
)