mirror of
https://codeberg.org/icewind/nextcloud-config-parser.git
synced 2026-06-03 08:34:13 +02:00
fix ipv6 database host
This commit is contained in:
parent
f694ccb408
commit
70543db580
3 changed files with 54 additions and 9 deletions
16
src/lib.rs
16
src/lib.rs
|
|
@ -348,14 +348,12 @@ fn split_host(host: &str) -> (&str, Option<u16>, Option<&str>) {
|
|||
if host.starts_with('/') {
|
||||
return ("localhost", None, Some(host));
|
||||
}
|
||||
let mut parts = host.split(':');
|
||||
let host = parts.next().unwrap();
|
||||
match parts
|
||||
.next()
|
||||
.map(|port_or_socket| u16::from_str(port_or_socket).map_err(|_| port_or_socket))
|
||||
{
|
||||
Some(Ok(port)) => (host, Some(port), None),
|
||||
Some(Err(socket)) => (host, None, Some(socket)),
|
||||
None => (host, None, None),
|
||||
let (host, port_or_socket) = host.rsplit_once(':').unwrap_or((host, ""));
|
||||
if port_or_socket.is_empty() {
|
||||
return (host, None, None);
|
||||
}
|
||||
match u16::from_str(port_or_socket) {
|
||||
Ok(port) => (host, Some(port), None),
|
||||
Err(_) => (host, None, Some(port_or_socket)),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue