Add helpers to access full / bare jid as string

This commit is contained in:
Mickael Remond
2019-06-07 16:25:18 +02:00
parent ae153e1ee5
commit eb2b506e3b
2 changed files with 36 additions and 0 deletions
+11
View File
@@ -50,6 +50,17 @@ func NewJid(sjid string) (*Jid, error) {
return jid, nil
}
func (j *Jid) Full() string {
return j.Node + "@" + j.Domain + "/" + j.Resource
}
func (j *Jid) Bare() string {
return j.Node + "@" + j.Domain
}
// ============================================================================
// Helpers, for parsing / validation
func isUsernameValid(username string) bool {
invalidRunes := []rune{'@', '/', '\'', '"', ':', '<', '>'}
return strings.IndexFunc(username, isInvalid(invalidRunes)) < 0