@@ -10,6 +10,8 @@ RegExp _ipv6 =
1010RegExp _creditCard = RegExp (
1111 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})$' );
1212
13+ int _maxUrlLength = 2083 ;
14+
1315/// check if the string [str] is an email
1416bool isEmail (String str) {
1517 return _email.hasMatch (str.toLowerCase ());
@@ -32,7 +34,7 @@ bool isURL(String? str,
3234 List <String > hostBlacklist = const []}) {
3335 if (str == null ||
3436 str.isEmpty ||
35- str.length > 2083 ||
37+ str.length > _maxUrlLength ||
3638 str.startsWith ('mailto:' )) {
3739 return false ;
3840 }
@@ -43,7 +45,7 @@ bool isURL(String? str,
4345 // check protocol
4446 var split = str.split ('://' );
4547 if (split.length > 1 ) {
46- protocol = shift (split);
48+ protocol = shift (split)! . toLowerCase () ;
4749 if (! protocols.contains (protocol)) {
4850 return false ;
4951 }
@@ -94,7 +96,7 @@ bool isURL(String? str,
9496 // check hostname
9597 hostname = split.join ('@' );
9698 split = hostname.split (':' );
97- host = shift (split)! ;
99+ host = shift (split)! . toLowerCase () ;
98100 if (split.isNotEmpty) {
99101 portStr = split.join (':' );
100102 try {
0 commit comments