refactor uri scheme validation

This commit is contained in:
Fabian Freund
2025-07-30 22:04:22 +02:00
parent fe1708d471
commit 6bc93f7b7d
2 changed files with 7 additions and 2 deletions
+2 -2
View File
@@ -18,9 +18,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:universal_io/io.dart';
import 'package:weblibre/extensions/uri.dart';
final _domainRegex = RegExp(r'\.[a-zA-Z]{2,}$');
const _supportedSchemes = {'https', 'http', 'ftp', 'file', 'content', 'about'};
Uri? tryParseUrl(String? input, {bool eagerParsing = false}) {
if (input != null) {
@@ -42,7 +42,7 @@ Uri? tryParseUrl(String? input, {bool eagerParsing = false}) {
}
if (uri.authority.isNotEmpty) {
if (_supportedSchemes.contains(uri.scheme) || !uri.hasScheme) {
if (uri.hasSupportedScheme || !uri.hasScheme) {
return uri;
}
}