mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
Fix host trailing dot in Discover
This commit is contained in:
parent
19140af10d
commit
d21315e9fc
@ -6,6 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/emersion/go-vcard"
|
"github.com/emersion/go-vcard"
|
||||||
"github.com/emersion/go-webdav"
|
"github.com/emersion/go-webdav"
|
||||||
@ -30,11 +31,16 @@ func Discover(domain string) (string, error) {
|
|||||||
}
|
}
|
||||||
addr := addrs[0]
|
addr := addrs[0]
|
||||||
|
|
||||||
|
target := strings.TrimSuffix(addr.Target, ".")
|
||||||
|
if target == "" {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
u := url.URL{Scheme: "https"}
|
u := url.URL{Scheme: "https"}
|
||||||
if addr.Port == 443 {
|
if addr.Port == 443 {
|
||||||
u.Host = addr.Target
|
u.Host = addr.Target
|
||||||
} else {
|
} else {
|
||||||
u.Host = fmt.Sprintf("%v:%v", addr.Target, addr.Port)
|
u.Host = fmt.Sprintf("%v:%v", target, addr.Port)
|
||||||
}
|
}
|
||||||
return u.String(), nil
|
return u.String(), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user