From e77360a11c4946658dd5db83bc3b8d1a110a23e4 Mon Sep 17 00:00:00 2001 From: Sven Jacobs Date: Thu, 9 Mar 2023 08:44:26 +0100 Subject: [PATCH] feat: Remove obsolete Amazon Smile sanitizer (#156) --- .../app/leon/startup/ContainerInitializer.kt | 4 +- .../sanitizer/amazon/AmazonSmileSanitizer.kt | 50 ------------------- core-domain/src/main/res/values/strings.xml | 3 +- .../amazon/AmazonSmileSanitizerTest.kt | 39 --------------- .../sanitizer/newegg/NewEggSanitizerTest.kt | 4 +- 5 files changed, 4 insertions(+), 96 deletions(-) delete mode 100644 core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/amazon/AmazonSmileSanitizer.kt delete mode 100644 core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/amazon/AmazonSmileSanitizerTest.kt 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 e733df3a..844e46c8 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 @@ -1,6 +1,6 @@ /* * Léon - The URL Cleaner - * Copyright (C) 2022 Sven Jacobs + * 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 @@ -23,7 +23,6 @@ import com.svenjacobs.app.leon.core.domain.inject.AppContainer import com.svenjacobs.app.leon.core.domain.sanitizer.aliexpress.AliexpressSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.amazon.AmazonProductSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.amazon.AmazonSanitizer -import com.svenjacobs.app.leon.core.domain.sanitizer.amazon.AmazonSmileSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.aol.AolSearchSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.change.ChangeSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.ebay.EbaySanitizer @@ -60,7 +59,6 @@ class ContainerInitializer : DistinctInitializer { AliexpressSanitizer(), AmazonProductSanitizer(), AmazonSanitizer(), - AmazonSmileSanitizer(), AolSearchSanitizer(), ChangeSanitizer(), EbaySanitizer(), diff --git a/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/amazon/AmazonSmileSanitizer.kt b/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/amazon/AmazonSmileSanitizer.kt deleted file mode 100644 index 26d7ab03..00000000 --- a/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/amazon/AmazonSmileSanitizer.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Léon - The URL Cleaner - * Copyright (C) 2022 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.amazon - -import android.content.Context -import com.svenjacobs.app.leon.core.domain.R -import com.svenjacobs.app.leon.core.domain.sanitizer.Sanitizer -import com.svenjacobs.app.leon.core.domain.sanitizer.SanitizerId - -class AmazonSmileSanitizer : Sanitizer { - - override val id = SanitizerId("amazon_smile") - - override fun getMetadata(context: Context) = Sanitizer.Metadata( - name = context.getString(R.string.sanitizer_amazon_smile_name), - ) - - override fun invoke(input: String): String { - val result = - DOMAIN_REGEX.find( - input, - ) ?: return input - val group = result.groups[1] ?: return input - return input.replaceRange(group.range, "smile.amazon") - } - - override fun matchesDomain(input: String) = DOMAIN_REGEX.containsMatchIn( - input, - ) - - private companion object { - val DOMAIN_REGEX = Regex("^(?:https?://)?((?:www\\.)?amazon)\\.") - } -} diff --git a/core-domain/src/main/res/values/strings.xml b/core-domain/src/main/res/values/strings.xml index 0d01fa55..7f1c039e 100644 --- a/core-domain/src/main/res/values/strings.xml +++ b/core-domain/src/main/res/values/strings.xml @@ -1,6 +1,6 @@