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 = ; var res = xmppuri;// res == {// jid: 'user@example.com',// 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;// res == {// account: {// local: 'me',// domain: 'example.com',// bare: 'me@example.com',// full: 'me@example.com'// },// jid: {// local: 'user',// domain: 'example.com',// resource: 'res',// bare: 'user@example.com',// full: 'user@example.com/res'// },// action: 'subscribe'// }
The inverse operation can be done by using xmppuri.create
:
xmppuri;// res == 'xmpp://me@example.com/user@example.com?message;body=hi'
License
MIT
Created By
If you like this, follow @lancestout on twitter.