diff --git a/app/lib/extensions/uri.dart b/app/lib/extensions/uri.dart
index e9a36938..f1d2700f 100644
--- a/app/lib/extensions/uri.dart
+++ b/app/lib/extensions/uri.dart
@@ -17,6 +17,11 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
+
+const _supportedSchemes = {'https', 'http', 'ftp', 'file', 'content', 'about'};
+
extension UriX on Uri {
Uri get base => Uri.parse('$scheme://$authority');
+
+ bool get hasSupportedScheme => _supportedSchemes.contains(scheme);
}
diff --git a/app/lib/utils/uri_parser.dart b/app/lib/utils/uri_parser.dart
index 0f571589..fda07830 100644
--- a/app/lib/utils/uri_parser.dart
+++ b/app/lib/utils/uri_parser.dart
@@ -18,9 +18,9 @@
* along with this program. If not, see .
*/
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;
}
}