mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-09-12 15:02:17 +00:00
update host validation rule
This commit is contained in:
parent
0911aba08c
commit
07c7fc4836
@ -163,15 +163,12 @@ fn validate(host: &Entry) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn validate_host(value: &str) -> Result<(), String> {
|
fn validate_host(value: &str) -> Result<(), String> {
|
||||||
match gtk::gio::NetworkAddress::parse(value, 0) {
|
// https://docs.gtk.org/gio/property.SimpleProxyResolver.ignore-hosts.html
|
||||||
Ok(address) => {
|
match gtk::gio::NetworkAddress::parse(
|
||||||
use gtk::prelude::NetworkAddressExt;
|
value.trim_start_matches('.').trim_start_matches('*'),
|
||||||
if address.hostname() != value {
|
0,
|
||||||
Err("Hostname or IP address could not be parsed properly".to_string())
|
) {
|
||||||
} else {
|
Ok(_) => Ok(()),
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => Err(format!("Valid hostname or IP address is required: `{e}`")),
|
Err(e) => Err(format!("Valid hostname or IP address is required: `{e}`")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user