add ip detection
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import 'package:universal_io/io.dart';
|
||||||
|
|
||||||
final _domainRegex = RegExp(r'\.[a-zA-Z]{2,}$');
|
final _domainRegex = RegExp(r'\.[a-zA-Z]{2,}$');
|
||||||
const _supportedSchemes = {'https', 'http', 'ftp', 'file', 'content', 'about'};
|
const _supportedSchemes = {'https', 'http', 'ftp', 'file', 'content', 'about'};
|
||||||
|
|
||||||
@@ -9,6 +11,8 @@ Uri? tryParseUrl(String? input, {bool eagerParsing = false}) {
|
|||||||
if (uri.pathSegments.isNotEmpty) {
|
if (uri.pathSegments.isNotEmpty) {
|
||||||
if (_domainRegex.hasMatch(uri.pathSegments.first)) {
|
if (_domainRegex.hasMatch(uri.pathSegments.first)) {
|
||||||
uri = Uri.tryParse('https://$input');
|
uri = Uri.tryParse('https://$input');
|
||||||
|
} else if (InternetAddress.tryParse(uri.pathSegments.first) != null) {
|
||||||
|
uri = Uri.tryParse('https://$input');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user