mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-21 22:39:11 +00:00
Check if it's not ip to apply ""
This commit is contained in:
parent
4f903d8e4c
commit
cce54c8ba5
2 changed files with 13 additions and 2 deletions
10
lib/functions/is_ip.dart
Normal file
10
lib/functions/is_ip.dart
Normal file
|
@ -0,0 +1,10 @@
|
|||
bool isIpAddress(String value) {
|
||||
final ipv4Regexp = RegExp(r'^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$');
|
||||
final ipv6Regexp = RegExp(r'(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))');
|
||||
if (ipv4Regexp.hasMatch(value) || ipv6Regexp.hasMatch(value)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import 'package:segmented_button_slide/segmented_button_slide.dart';
|
|||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'package:adguard_home_manager/widgets/custom_checkbox_list_tile.dart';
|
||||
import 'package:adguard_home_manager/functions/is_ip.dart';
|
||||
import 'package:adguard_home_manager/widgets/list_bottom_sheet.dart';
|
||||
|
||||
import 'package:adguard_home_manager/providers/status_provider.dart';
|
||||
|
@ -79,9 +80,9 @@ class _ClientsModalState extends State<ClientsModal> {
|
|||
// ---- //
|
||||
}
|
||||
return _ClientLog(
|
||||
ip: e.ids[0],
|
||||
ip: isIpAddress(e.ids[0]) ? e.ids[0] : '"${e.ids[0]}"',
|
||||
name: name,
|
||||
ids: e.ids
|
||||
ids: e.ids.map((i) => isIpAddress(i) ? i : '"$i"').toList()
|
||||
);
|
||||
}).where(
|
||||
(c) => c.ip.contains(value.toLowerCase()) || (c.name != null && c.name!.toLowerCase().contains(value.toLowerCase()))
|
||||
|
|
Loading…
Add table
Reference in a new issue