# HG changeset patch # User Chris Jones # Date 1384024921 25200 # Node ID 4477c9f31f4300f0c2c60b24e38fb4783044b85b # Parent ccfebbd9f49b6a75a27f9ed9bf2ac5f51cc468e5 Added a JID.Bare() function, to product the bare JID as defined in the RFC. diff -r ccfebbd9f49b -r 4477c9f31f43 xmpp/structs.go --- a/xmpp/structs.go Sat Nov 09 12:09:37 2013 -0700 +++ b/xmpp/structs.go Sat Nov 09 12:22:01 2013 -0700 @@ -183,6 +183,15 @@ return string(j[slash+1:]) } +// Returns the bare JID, which is the JID without the resource part. +func (j JID) Bare() JID { + node := j.Node() + if node == "" { + return JID(j.Domain()) + } + return JID(fmt.Sprintf("%s@%s", node, j.Domain())) +} + func (s *stream) String() string { var buf bytes.Buffer buf.WriteString(`