@@ -10,6 +10,8 @@ RegExp _ipv6 =
10
10
RegExp _creditCard = RegExp (
11
11
r'^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$' );
12
12
13
+ int _maxUrlLength = 2083 ;
14
+
13
15
/// check if the string [str] is an email
14
16
bool isEmail (String str) {
15
17
return _email.hasMatch (str.toLowerCase ());
@@ -32,7 +34,7 @@ bool isURL(String? str,
32
34
List <String > hostBlacklist = const []}) {
33
35
if (str == null ||
34
36
str.isEmpty ||
35
- str.length > 2083 ||
37
+ str.length > _maxUrlLength ||
36
38
str.startsWith ('mailto:' )) {
37
39
return false ;
38
40
}
@@ -43,7 +45,7 @@ bool isURL(String? str,
43
45
// check protocol
44
46
var split = str.split ('://' );
45
47
if (split.length > 1 ) {
46
- protocol = shift (split);
48
+ protocol = shift (split)! . toLowerCase () ;
47
49
if (! protocols.contains (protocol)) {
48
50
return false ;
49
51
}
@@ -94,7 +96,7 @@ bool isURL(String? str,
94
96
// check hostname
95
97
hostname = split.join ('@' );
96
98
split = hostname.split (':' );
97
- host = shift (split)! ;
99
+ host = shift (split)! . toLowerCase () ;
98
100
if (split.isNotEmpty) {
99
101
portStr = split.join (':' );
100
102
try {
0 commit comments