major update
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import 'package:lensai/extensions/nullable.dart';
|
||||
import 'package:lensai/utils/uri_parser.dart' as uri_parser;
|
||||
|
||||
String? validateUrl(
|
||||
String? value, {
|
||||
bool requireAuthority = true,
|
||||
bool eagerParsing = true,
|
||||
bool onlyHttpProtocol = false,
|
||||
bool required = true,
|
||||
}) {
|
||||
if (value.isEmpty) {
|
||||
if (required) {
|
||||
return 'URL must be provided';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (uri_parser.tryParseUrl(value, eagerParsing: eagerParsing)
|
||||
case final Uri url) {
|
||||
if (!requireAuthority || url.authority.isNotEmpty) {
|
||||
if (!onlyHttpProtocol ||
|
||||
(url.isScheme('https') || url.isScheme('http'))) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 'Inavlid URL';
|
||||
}
|
||||
@@ -23,6 +23,10 @@ class LRUCache<K, V> {
|
||||
_capacity = capacity;
|
||||
}
|
||||
|
||||
bool contains(K key) {
|
||||
return _cache.containsKey(key);
|
||||
}
|
||||
|
||||
V? get(K key) {
|
||||
final value = _cache.remove(key); // Temporarily remove the item.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user