Skip to content

Commit

Permalink
fix EsURL parse
Browse files Browse the repository at this point in the history
  • Loading branch information
dmiasn committed Oct 24, 2022
1 parent 9f2c3e3 commit fc6c00a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Utils/Common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package Utils
import (
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
"os"
"strings"
"time"
)

Expand Down Expand Up @@ -42,6 +44,10 @@ func ParseEsUrl(u string) string {
if s.Port() != "" {
port = s.Port()
}
domain = s.Host
if strings.Contains(s.Host, ":") {
domain, port, _ = net.SplitHostPort(s.Host)
} else {
domain = s.Host
}
return fmt.Sprintf("%s://%s:%s", schema, domain, port)
}

0 comments on commit fc6c00a

Please sign in to comment.