mirror of
https://codeberg.org/icewind/nextcloud-config-parser.git
synced 2026-06-03 08:34:13 +02:00
fix non-port ipv6
This commit is contained in:
parent
f9650877ea
commit
20d09d186d
3 changed files with 23 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -797,7 +797,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nextcloud-config-parser"
|
name = "nextcloud-config-parser"
|
||||||
version = "0.15.1"
|
version = "0.15.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"form_urlencoded",
|
"form_urlencoded",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nextcloud-config-parser"
|
name = "nextcloud-config-parser"
|
||||||
description = "Rust parser for nextcloud config files"
|
description = "Rust parser for nextcloud config files"
|
||||||
version = "0.15.1"
|
version = "0.15.2"
|
||||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
|
|
||||||
22
src/lib.rs
22
src/lib.rs
|
|
@ -348,7 +348,15 @@ fn split_host(host: &str) -> (&str, Option<u16>, Option<&str>) {
|
||||||
if host.starts_with('/') {
|
if host.starts_with('/') {
|
||||||
return ("localhost", None, Some(host));
|
return ("localhost", None, Some(host));
|
||||||
}
|
}
|
||||||
let (host, port_or_socket) = host.rsplit_once(':').unwrap_or((host, ""));
|
let (host, port_or_socket) = if host.starts_with('[') {
|
||||||
|
if let Some(pos) = host.rfind("]:") {
|
||||||
|
(&host[0..pos + 1], &host[pos + 2..])
|
||||||
|
} else {
|
||||||
|
(host, "")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
host.rsplit_once(':').unwrap_or((host, ""))
|
||||||
|
};
|
||||||
if port_or_socket.is_empty() {
|
if port_or_socket.is_empty() {
|
||||||
return (host, None, None);
|
return (host, None, None);
|
||||||
}
|
}
|
||||||
|
|
@ -357,3 +365,15 @@ fn split_host(host: &str) -> (&str, Option<u16>, Option<&str>) {
|
||||||
Err(_) => (host, None, Some(port_or_socket)),
|
Err(_) => (host, None, Some(port_or_socket)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_spit_host() {
|
||||||
|
assert_eq!(("localhost", None, None), split_host("localhost"));
|
||||||
|
assert_eq!(("localhost", Some(123), None), split_host("localhost:123"));
|
||||||
|
assert_eq!(
|
||||||
|
("localhost", None, Some("foo")),
|
||||||
|
split_host("localhost:foo")
|
||||||
|
);
|
||||||
|
assert_eq!(("[::1]", None, None), split_host("[::1]"));
|
||||||
|
assert_eq!(("[::1]", Some(123), None), split_host("[::1]:123"));
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue