-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add Salesforce sanitizer, covers #302 * chore: adjust SalesforceParametersSanitizer --------- Co-authored-by: Sven Jacobs <[email protected]>
- Loading branch information
1 parent
8968b71
commit c61d66d
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...com/svenjacobs/app/leon/core/domain/sanitizer/salesforce/SalesforceParametersSanitizer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Léon - The URL Cleaner | ||
* Copyright (C) 2024 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.salesforce | ||
|
||
import android.content.Context | ||
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 SalesforceParametersSanitizer : | ||
RegexSanitizer( | ||
// see https://help.salesforce.com/s/articleView?id=sf.mc_gai_utm_parameters.htm&type=5 | ||
RegexFactory.ofWildcardParameter("utm_|sfmc_"), | ||
) { | ||
|
||
override val id = SanitizerId("salesforce") | ||
|
||
override fun getMetadata(context: Context) = Sanitizer.Metadata( | ||
name = context.getString(R.string.sanitizer_salesforce_name), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...svenjacobs/app/leon/core/domain/sanitizer/salesforce/SalesforceParametersSanitizerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Léon - The URL Cleaner | ||
* Copyright (C) 2024 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.salesforce | ||
|
||
import io.kotest.core.spec.style.WordSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
class SalesforceParametersSanitizerTest : | ||
WordSpec( | ||
{ | ||
val sanitizer = SalesforceParametersSanitizer() | ||
|
||
"invoke" should { | ||
|
||
"remove sfmc_activityid parameter as per #302" { | ||
sanitizer( | ||
"https://www.geox.com/it-IT/uomo/scarpe/stivaletti/?sfmc_activityid=a5542c58-11be-4f33-8dd5-5e0ebeae30f2", | ||
) shouldBe "https://www.geox.com/it-IT/uomo/scarpe/stivaletti/" | ||
} | ||
} | ||
}, | ||
) |