add ip detection

This commit is contained in:
Fabian Freund
2025-06-02 22:21:39 +02:00
parent 15ece55dfe
commit f6e0f665ce
+4
View File
@@ -1,3 +1,5 @@
import 'package:universal_io/io.dart';
final _domainRegex = RegExp(r'\.[a-zA-Z]{2,}$');
const _supportedSchemes = {'https', 'http', 'ftp', 'file', 'content', 'about'};
@@ -9,6 +11,8 @@ Uri? tryParseUrl(String? input, {bool eagerParsing = false}) {
if (uri.pathSegments.isNotEmpty) {
if (_domainRegex.hasMatch(uri.pathSegments.first)) {
uri = Uri.tryParse('https://$input');
} else if (InternetAddress.tryParse(uri.pathSegments.first) != null) {
uri = Uri.tryParse('https://$input');
}
}
}