Skip to content

Commit ba87d10

Browse files
fix: Normalize pre-bracketed IPv6 addresses before adding port
Handle edge case where host might already have brackets from ADO-style connection strings or failed parsing by trimming brackets before re-adding.
1 parent 0bf73ab commit ba87d10

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

msdsn/conn_str.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ func (p Config) URL() *url.URL {
689689
if p.Port > 0 {
690690
// IPv6 addresses need brackets when combined with a port
691691
if strings.Contains(host, ":") {
692+
// Normalize any pre-bracketed IPv6 host (e.g., "[fe80::1]") before adding port
693+
host = strings.Trim(host, "[]")
692694
host = fmt.Sprintf("[%s]:%d", host, p.Port)
693695
} else {
694696
host = fmt.Sprintf("%s:%d", host, p.Port)

0 commit comments

Comments
 (0)