# HG changeset patch # User Emmanuel Gil Peyrot # Date 1287503325 -7200 # Node ID 60c80751cfa51dbd8c743a915b833afd0b142417 # Parent 06abc804e2abe1f4bede2efb459dab4f56d09c61 JID handling conforming to the RFC. diff --git a/util.js b/util.js --- a/util.js +++ b/util.js @@ -25,21 +25,23 @@ util.makeRandomId = function() { }; var JID = function(jid) { - var a = jid.indexOf('@'); - var b = jid.indexOf('/', a); this.full = jid; - if (b == -1) { + + var s = jid.indexOf('/'); + if (s == -1) this.resource = ''; - } else { - this.resource = jid.substring(b+1); - jid = jid.substring(0, b); + else { + this.resource = jid.substring(s+1); + jid = jid.substr(0, s); } + + var a = jid.indexOf('@'); if (a == -1) { this.user = ''; this.server = jid; } else { - this.user = jid.substring(0, a); - this.server = jid.substring(a+1); + this.user = jid.substr(0, a); + this.server = jid.substr(a+1); } this.bare = jid; };