Skip to content

Commit

Permalink
feat: Add eBay sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
svenjacobs committed Oct 1, 2022
1 parent 10c22b2 commit ae8043a
Show file tree
Hide file tree
Showing 13 changed files with 193 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Version 1.2.0

_2022-10-01_

- Add eBay sanitizer

## Version 1.1.0

_2022-09-18_
Expand Down
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ android {
applicationId = "com.svenjacobs.app.leon"
minSdk = Android.minSdk
targetSdk = Android.targetSdk
versionCode = 236
versionName = "1.1.0"
versionCode = 237
versionName = "1.2.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -123,6 +123,7 @@ dependencies {
implementation(project(":feature-sanitizer-amazon"))
implementation(project(":feature-sanitizer-amazon-smile"))
implementation(project(":feature-sanitizer-aol-search"))
implementation(project(":feature-sanitizer-ebay"))
implementation(project(":feature-sanitizer-empty-parameters"))
implementation(project(":feature-sanitizer-facebook"))
implementation(project(":feature-sanitizer-flipkart"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.svenjacobs.app.leon.feature.sanitizer.amazon.AmazonProductSanitizerRe
import com.svenjacobs.app.leon.feature.sanitizer.amazon.AmazonSanitizerRegistration
import com.svenjacobs.app.leon.feature.sanitizer.amazon.smile.AmazonSmileSanitizerRegistration
import com.svenjacobs.app.leon.feature.sanitizer.aol.search.AolSearchSanitizerRegistration
import com.svenjacobs.app.leon.feature.sanitizer.ebay.EbaySanitizerRegistration
import com.svenjacobs.app.leon.feature.sanitizer.emptyparameters.EmptyParametersSanitizerRegistration
import com.svenjacobs.app.leon.feature.sanitizer.facebook.FacebookSanitizerRegistration
import com.svenjacobs.app.leon.feature.sanitizer.flipkart.FlipkartSanitizerRegistration
Expand Down Expand Up @@ -52,6 +53,7 @@ class ComponentInitializer : DistinctInitializer<Unit> {
AmazonSanitizerRegistration(),
AmazonSmileSanitizerRegistration(),
AolSearchSanitizerRegistration(),
EbaySanitizerRegistration(),
EmptyParametersSanitizerRegistration(),
FacebookSanitizerRegistration(),
FlipkartSanitizerRegistration(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SettingsSanitizersScreenViewModel(
enabled = state.enabled,
)
}
.sortedBy { it.name }
.sortedBy { it.name.lowercase() }
.toImmutableList(),
)
}.stateIn(
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/play/release-notes/de-DE/default.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
- Reiniger für YouTube-Weiterleitungslinks hinzugefügt
- Reiniger für Amazon-Seiten, die keine Produktseiten sind, hinzugefügt
- Reiniger für Youtu.be Kurz-URLs hinzugefügt
- Die App kann als Browser registriert werden
- eBay Reiniger hinzugefügt
5 changes: 1 addition & 4 deletions app/src/main/play/release-notes/en-US/default.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
- Add sanitizer for YouTube redirection links
- Add sanitizer for Amazon non-product pages
- Add Youtu.be short URL sanitizer
- Add feature to register app as a browser
- Add eBay sanitizer
26 changes: 26 additions & 0 deletions feature-sanitizer-ebay/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

plugins {
`feature-sanitizer`
}

android {
namespace = "com.svenjacobs.app.leon.feature.sanitizer.ebay"
resourcePrefix("feat_sanitizer_ebay_")
}
19 changes: 19 additions & 0 deletions feature-sanitizer-ebay/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ 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 <http://www.gnu.org/licenses/>.
-->

<manifest />
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

package com.svenjacobs.app.leon.feature.sanitizer.ebay

import com.svenjacobs.app.leon.core.common.regex.RegexFactory
import com.svenjacobs.app.leon.core.domain.sanitizer.RegexSanitizer

class EbaySanitizer : RegexSanitizer(
regex = RegexFactory.AllParameters,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

package com.svenjacobs.app.leon.feature.sanitizer.ebay

import android.content.Context
import com.svenjacobs.app.leon.core.domain.sanitizer.Sanitizer
import com.svenjacobs.app.leon.core.domain.sanitizer.SanitizerId
import com.svenjacobs.app.leon.core.domain.sanitizer.SanitizerRegistration

class EbaySanitizerRegistration(
private val sanitizerProvider: () -> EbaySanitizer = { EbaySanitizer() },
) : SanitizerRegistration {

override val sanitizer: Sanitizer
get() = sanitizerProvider()

override val id = SanitizerId("ebay")

override val hasSettingsScreen = false

override fun getName(context: Context) = context.getString(R.string.feat_sanitizer_ebay_name)

override fun matchesDomain(input: String) = DOMAIN_REGEX.containsMatchIn(input)

private companion object {
private val DOMAIN_REGEX = Regex("ebay\\..+/itm/")
}
}
21 changes: 21 additions & 0 deletions feature-sanitizer-ebay/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ 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 <http://www.gnu.org/licenses/>.
-->

<resources>
<string name="feat_sanitizer_ebay_name" translatable="false">eBay</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

package com.svenjacobs.app.leon.feature.sanitizer.amazon

import com.svenjacobs.app.leon.feature.sanitizer.ebay.EbaySanitizer
import io.kotest.core.spec.style.WordSpec
import io.kotest.matchers.shouldBe

class EbaySanitizerTest : WordSpec(
{

"invoke" should {

"remove all parameters from eBay article URL" {
val sanitizer = EbaySanitizer()
val result = sanitizer(
"https://www.ebay.de/itm/271784973135?mkcid=16&mkevt=1&mkrid=707-127654" +
"-2357-0&ssspo=rMbbkKXARCW&sssrc=2348624&ssuid=Bw-3_LUXSsm&widget_ver=art" +
"emis&media=MORE",
)

result shouldBe "https://www.ebay.de/itm/271784973135"
}
}
},
)
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include(
":feature-sanitizer-amazon",
":feature-sanitizer-amazon-smile",
":feature-sanitizer-aol-search",
":feature-sanitizer-ebay",
":feature-sanitizer-empty-parameters",
":feature-sanitizer-facebook",
":feature-sanitizer-flipkart",
Expand Down

0 comments on commit ae8043a

Please sign in to comment.