Needling Perl Mongers

    xmpp-uri

    2.1.0 • Public • Published

    XMPP-URI

    Parse and Create XMPP URIs

    Build Status Dependency Status devDependency Status

    Browser Support

    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:user@example.com?message;body=hi');
    // 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.parse('xmpp://me@example.com/user@example.com/res?subscribe');
    // 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.create({
        account: 'me@example.com',
        jid: 'user@example.com',
        action: 'message',
        parameters: {
            body: 'hi'
        }
    });
    // res == 'xmpp://me@example.com/user@example.com?message;body=hi'

    License

    MIT

    Created By

    If you like this, follow @lancestout on twitter.

    Keywords

    Install

    npm i xmpp-uri

    DownloadsWeekly Downloads

    4

    Version

    2.1.0

    License

    MIT

    Last publish

    Collaborators

    • andyet-ops
    • lancestout