snowmtl: fix image intercept (#6529)
This commit is contained in:
parent
7abb7e3c16
commit
e11aafbd0f
|
@ -1,7 +1,7 @@
|
|||
ext {
|
||||
extName = 'Snow Machine Translations'
|
||||
extClass = '.Snowmtl'
|
||||
extVersionCode = 2
|
||||
extVersionCode = 3
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import kotlin.math.sqrt
|
|||
// The Interceptor joins the captions and pages of the manga.
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
class ComposedImageInterceptor(
|
||||
private val baseUrl: String,
|
||||
baseUrl: String,
|
||||
private val client: OkHttpClient,
|
||||
) : Interceptor {
|
||||
|
||||
|
@ -44,11 +44,16 @@ class ComposedImageInterceptor(
|
|||
"normal" to Pair<String, Typeface?>("$baseUrl/images/normal.ttf", null),
|
||||
)
|
||||
|
||||
private val imageRegex = Regex(
|
||||
"$baseUrl.*?\\.(webp|png|jpg|jpeg)#\\[.*?]",
|
||||
RegexOption.IGNORE_CASE,
|
||||
)
|
||||
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
val url = request.url.toString()
|
||||
|
||||
val isPageImageUrl = url.contains("${baseUrl.substringAfterLast("/")}/storage/", true)
|
||||
val isPageImageUrl = imageRegex.containsMatchIn(url)
|
||||
if (isPageImageUrl.not()) {
|
||||
return chain.proceed(request)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue