Skip to content

Commit

Permalink
fix: Prevent dumb users from using blank baseUrls
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudemirovsky committed Nov 26, 2023
1 parent 15fbd21 commit 01aab11
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class GogoAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {

override val name = "Gogoanime"

override val baseUrl by lazy { preferences.getString(PREF_DOMAIN_KEY, PREF_DOMAIN_DEFAULT)!! }
override val baseUrl by lazy {
preferences.getString(PREF_DOMAIN_KEY, PREF_DOMAIN_DEFAULT).orEmpty()
.trim().ifBlank { PREF_DOMAIN_DEFAULT }
}

override val lang = "en"

Expand Down Expand Up @@ -281,7 +284,7 @@ class GogoAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {

setOnPreferenceChangeListener { _, newValue ->
runCatching {
val value = (newValue as String).trim().ifEmpty { PREF_DOMAIN_DEFAULT }
val value = (newValue as String).trim().ifBlank { PREF_DOMAIN_DEFAULT }
Toast.makeText(screen.context, "Restart Aniyomi to apply new setting.", Toast.LENGTH_LONG).show()
preferences.edit().putString(key, value).commit()
}.getOrDefault(false)
Expand Down

0 comments on commit 01aab11

Please sign in to comment.