mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
trim [ and ] from host string before used to connect by TcpStream (#1818)
This commit is contained in:
parent
c744cb7f60
commit
4e3ff3644f
@ -17,7 +17,10 @@ pub enum Socket {
|
||||
|
||||
impl Socket {
|
||||
pub async fn connect_tcp(host: &str, port: u16) -> io::Result<Self> {
|
||||
TcpStream::connect((host, port)).await.map(Socket::Tcp)
|
||||
// Trim square brackets from host if it's an IPv6 address as the `url` crate doesn't do that.
|
||||
TcpStream::connect((host.trim_matches(|c| c == '[' || c == ']'), port))
|
||||
.await
|
||||
.map(Socket::Tcp)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user