Extract host part from homeserver url
This commit is contained in:
parent
03e1e564f6
commit
ff6a07e592
|
@ -1,12 +1,21 @@
|
|||
package matrix
|
||||
|
||||
import "maunium.net/go/mautrix/id"
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
func makeUserID(userIdentifier, homeserverURL string) (id.UserID, error) {
|
||||
userID := id.UserID(userIdentifier)
|
||||
localpart, _, err := userID.Parse()
|
||||
if err != nil {
|
||||
userID = id.NewUserID(userIdentifier, homeserverURL)
|
||||
url, err := url.Parse(homeserverURL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
userID = id.NewUserID(userIdentifier, url.Host)
|
||||
if _, _, err := userID.ParseAndValidate(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue