Skip to content

Commit

Permalink
trim [ and ] from host string before used to connect by TcpStream
Browse files Browse the repository at this point in the history
  • Loading branch information
Van Tien Thanh committed Apr 19, 2022
1 parent b934f82 commit 4c9fa90
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sqlx-core/src/net/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ 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)
TcpStream::connect((host.trim_matches(|c| c == "[" || c == "]"), port))
.await
.map(Socket::Tcp)
}

#[cfg(unix)]
Expand Down

0 comments on commit 4c9fa90

Please sign in to comment.