Skip to content

Commit

Permalink
RedirectFixActivity: only follow redirects with URL cleaning enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Atemu committed May 13, 2023
1 parent 2c6f019 commit 3e1b411
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class RedirectFixActivity : DaggerAppCompatActivity() {
@Inject lateinit var redirectFixer: RedirectFixer
@Inject lateinit var urlFix: UrlFix
@Inject lateinit var schedulingStrategy: SchedulingStrategy
@Inject lateinit var cleanUrlsPreferences: CleanUrlsPreferences

private var disposable: Disposable? = null

Expand Down Expand Up @@ -57,10 +58,15 @@ class RedirectFixActivity : DaggerAppCompatActivity() {
}

private val redirectTransformer = MaybeTransformer<HttpUrl, HttpUrl> { source ->
source.flatMap { httpUrl ->
redirectFixer
.followRedirects(httpUrl)
.toMaybe()
if (cleanUrlsPreferences.isEnabled) {
source.flatMap { httpUrl ->
redirectFixer
.followRedirects(httpUrl)
.toMaybe()
}
} else {
// Identity; do nothing
source
}
}

Expand Down

0 comments on commit 3e1b411

Please sign in to comment.