diff fdsq.js @ 56:99bd1d1ac071

Migration to node-xmpp, done!
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 10 Aug 2011 15:11:22 -0700
parents 0d3f18bb1d36
children
line wrap: on
line diff
--- a/fdsq.js
+++ b/fdsq.js
@@ -19,41 +19,14 @@
 
 'use strict';
 
-var sha1hex = require('sha1').hex;
+var JID = require('node-xmpp').JID;
 
 var fdsq = exports;
-fdsq.makeRandomId = function() {
-	return sha1hex(Date()+Math.random());
-};
-
-var JID = function(jid) {
-	this.full = jid;
-
-	var s = jid.indexOf('/');
-	if (s == -1)
-		this.resource = '';
-	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.substr(0, a);
-		this.server = jid.substr(a+1);
-	}
-	this.bare = jid;
-};
 
 fdsq.toBare = function(jid) {
-	var j = new JID(jid);
-	return j.bare;
+	return new JID(jid).bare().toString();
 };
 
 fdsq.toResource = function(jid) {
-	var j = new JID(jid);
-	return j.resource;
+	return new JID(jid).resource;
 };