[skip ci] 详细dd异常信息

This commit is contained in:
Xwite
2023-03-15 22:08:07 +08:00
parent 3b951915f3
commit 61ff31d441

View File

@@ -93,12 +93,12 @@ object UrlUtil {
}
/* 获取合法的文件后缀 */
fun getSuffix(url: String, default: String? = null): String {
val suffix = url.substringAfterLast(".").substringBeforeLast(",")
fun getSuffix(str: String, default: String? = null): String {
val suffix = str.substringAfterLast(".").substringBeforeLast(",")
//检查截取的后缀字符是否合法 [a-zA-Z0-9]
val fileSuffixRegex = Regex("^[a-z\\d]+$", RegexOption.IGNORE_CASE)
return if (suffix.length > 5 || !suffix.matches(fileSuffixRegex)) {
default ?: throw IllegalArgumentException("Cannot find illegal suffix")
default ?: throw IllegalArgumentException("Cannot find illegal suffix:\n target: $str\nsuffix: $suffix")
} else {
suffix
}