Added a JID.Bare() function, to product the bare JID as defined in the RFC.
--- 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(`<stream:stream xmlns="`)