UrlUtil.getFileName先尝试截取

This commit is contained in:
Xwite
2023-03-15 22:00:13 +08:00
parent f1bf49982f
commit 3b951915f3
2 changed files with 2 additions and 2 deletions
@@ -450,7 +450,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
} }
// 后缀 // 后缀
val suffix: String = name.substringAfterLast(".") val suffix: String = UrlUtil.getSuffix(name)
// txt epub umd pdf等文件 // txt epub umd pdf等文件
val isSupported: Boolean = AppPattern.bookFileRegex.matches(name) val isSupported: Boolean = AppPattern.bookFileRegex.matches(name)
@@ -44,7 +44,7 @@ object UrlUtil {
// 如果获取到后缀可直接截取链接 // 如果获取到后缀可直接截取链接
if (getSuffix(fileUrl, "") != "") return fileUrl.substringAfterLast("/") if (getSuffix(fileUrl, "") != "") return fileUrl.substringAfterLast("/")
return kotlin.runCatching { return kotlin.runCatching {
var fileName: String var fileName: String = ""
val url = URL(fileUrl) val url = URL(fileUrl)
val conn: HttpURLConnection = url.openConnection() as HttpURLConnection val conn: HttpURLConnection = url.openConnection() as HttpURLConnection
// HEAD方式获取返回头信息 // HEAD方式获取返回头信息