mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-03 09:27:41 +08:00
修复错误的 URL 有效性验证正则表达式 (#286)
This commit is contained in:
parent
17830f10df
commit
0eab5dcaa0
@ -211,7 +211,7 @@ class CommonUtils private constructor() {
|
|||||||
//是否合法的url
|
//是否合法的url
|
||||||
fun checkUrl(urls: String?, emptyResult: Boolean): Boolean {
|
fun checkUrl(urls: String?, emptyResult: Boolean): Boolean {
|
||||||
if (TextUtils.isEmpty(urls)) return emptyResult
|
if (TextUtils.isEmpty(urls)) return emptyResult
|
||||||
val regex = "^(https?|ftp|file)://[-a-zA-Z\\d+&@#/%?=~_|!:,.;\\[\\]]*[-a-zA-Z\\d+&@#/%=~_|\\[\\]]"
|
val regex = "^https?://(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$"
|
||||||
val pat = Pattern.compile(regex)
|
val pat = Pattern.compile(regex)
|
||||||
val mat = pat.matcher(urls?.trim() ?: "")
|
val mat = pat.matcher(urls?.trim() ?: "")
|
||||||
return mat.matches()
|
return mat.matches()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user