Template:DekiScript:Uri

<% module.exports = buildAPI({
 
    // Decompose a URI into its component parts. (Obsoletes uri.parse)
    // [See also](http://developer.mindtouch.com/en/docs/DekiScript/Reference/DekiScript_Functions_and_Variables/Uri.Parts)
    parts: function (str) {
        var p = kuma.url.parse(str, true);
 
        var out = {
            host: p.hostname,
            port: p.port,
            path: p.pathname.substr(1).split('/'),
            fragment: p.hash,
            query: p.query,
            scheme: p.protocol
        };
 
        if (p.auth) {
            var auth_parts = p.auth.split(':');
            out.user = auth_parts[0];
            out.password = auth_parts[1];
        }
 
        return out;
    },
    
    // Encode text as a URI component.
    // [See also](http://developer.mindtouch.com/en/docs/DekiScript/Reference/DekiScript_Functions_and_Variables/Uri.Encode)
    encode: function (str) {
        return encodeURI(str);
    }
 
}); %>
Search for pages that use Template:DekiScript:Uri to see example use cases and how many pages use this macro.

Document Tags and Contributors

Contributors to this page: lmorchard
Last updated by: lmorchard,