mirror of
https://github.com/amir1376/ab-download-manager.git
synced 2025-02-20 11:43:24 +08:00
fix file name not detected from server sometimes
This commit is contained in:
parent
8bc36fce23
commit
17ec9277b4
@ -3,7 +3,8 @@ package ir.amirab.downloader.connection.response.headers
|
||||
import java.net.URLDecoder
|
||||
|
||||
fun extractFileNameFromContentDisposition(contentDispositionValue: String): String? {
|
||||
val utf8Regex = """filename\*=UTF-8''(?<fileName>[\w%\-\.]+)(?:; ?|${'$'})""".toRegex()
|
||||
val utf8Regex = """filename\*=UTF-8''(?<fileName>[\w%\-\.]+)(?:; ?|${'$'})"""
|
||||
.toRegex(RegexOption.IGNORE_CASE)
|
||||
utf8Regex.find(contentDispositionValue)
|
||||
?.groups?.get("fileName")
|
||||
?.value?.let {
|
||||
@ -12,7 +13,8 @@ fun extractFileNameFromContentDisposition(contentDispositionValue: String): Stri
|
||||
}?.let {
|
||||
return it
|
||||
}
|
||||
val asciiRegex = """filename=(["']?)(?<fileName>.*?[^\\])\1(?:; ?|$)""".toRegex()
|
||||
val asciiRegex = """filename=(["']?)(?<fileName>.*?[^\\])\1(?:; ?|$)"""
|
||||
.toRegex(RegexOption.IGNORE_CASE)
|
||||
asciiRegex.find(contentDispositionValue)
|
||||
?.groups
|
||||
?.get("fileName")
|
||||
|
Loading…
x
Reference in New Issue
Block a user