fix(en/gogoanime): Don't allow blank baseUrl (#2556)

This commit is contained in:
Claudemirovsky 2023-11-26 12:43:42 -03:00 committed by GitHub
parent 15fbd2149f
commit 39e78c181e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -7,7 +7,7 @@ ext {
extName = 'Gogoanime'
pkgNameSuffix = 'en.gogoanime'
extClass = '.GogoAnime'
extVersionCode = 77
extVersionCode = 78
libVersion = '13'
}

View File

@ -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"
@ -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)