xmpp-uri
v2.1.0
Published
Parse XMPP URIs
Downloads
6
Readme
XMPP-URI
Parse and Create XMPP URIs
What is this?
The xmpp-uri
module is for both parsing an XMPP URI to extract action commands and parameters, and creating a URI based on an action. Since XMPP URIs use ;
to separate values in the querystring, the normal URL parsing libs don't work as-is.
Installing
$ npm install xmpp-uri
Building bundled/minified version (for AMD, etc)
$ make
The bundled and minified files will be in the generated build
directory.
Usage
var xmppuri = require('xmpp-uri');
var res = xmppuri.parse('xmpp:[email protected]?message;body=hi');
// res == {
// jid: '[email protected]',
// action: 'message',
// parameters: {
// body: 'hi'
// }
// }
Most use cases will be with xmpp:
URIs, but you can also use xmpp://
to specify
a specific account to use for the action:
var res = xmppuri.parse('xmpp://[email protected]/[email protected]/res?subscribe');
// res == {
// account: {
// local: 'me',
// domain: 'example.com',
// bare: '[email protected]',
// full: '[email protected]'
// },
// jid: {
// local: 'user',
// domain: 'example.com',
// resource: 'res',
// bare: '[email protected]',
// full: '[email protected]/res'
// },
// action: 'subscribe'
// }
The inverse operation can be done by using xmppuri.create
:
xmppuri.create({
account: '[email protected]',
jid: '[email protected]',
action: 'message',
parameters: {
body: 'hi'
}
});
// res == 'xmpp://[email protected]/[email protected]?message;body=hi'
License
MIT
Created By
If you like this, follow @lancestout on twitter.