优化:检查合法的URL时支持IPv6地址(例如:主动控制·客户端的服务地址)

This commit is contained in:
pppscn 2022-10-05 19:56:35 +08:00
parent 35151aa924
commit c2ab087155
2 changed files with 1 additions and 2 deletions

View File

@ -36,7 +36,6 @@ import com.xuexiang.xui.widget.dialog.materialdialog.DialogAction
import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
import com.xuexiang.xutil.XUtil
@Suppress("PrivatePropertyName", "PropertyName")
@Page(name = "主动控制·客户端")
class ClientFragment : BaseFragment<FragmentClientBinding?>(),

View File

@ -243,7 +243,7 @@ class CommonUtils private constructor() {
//是否合法的url
fun checkUrl(urls: String?, emptyResult: Boolean): Boolean {
if (TextUtils.isEmpty(urls)) return emptyResult
val regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"
val regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;\\[\\]]*[-a-zA-Z0-9+&@#/%=~_|\\[\\]]"
val pat = Pattern.compile(regex)
val mat = pat.matcher(urls?.trim() ?: "")
return mat.matches()