function _asFormatted(uri, skipEncoding) {
        var encoder = !skipEncoding
            ? encodeURIComponentFast
            : encodeURIComponentMinimal;
        var res = '';
        var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
        if (scheme) {
            res += scheme;
            res += ':';
        }
        if (authority || scheme === 'file') {
            res += _slash;
            res += _slash;
        }
        if (authority) {
            var idx = authority.indexOf('@');
            if (idx !== -1) {
                // <user>@<auth>
                var userinfo = authority.substr(0, idx);
                authority = authority.substr(idx + 1);
                idx = userinfo.indexOf(':');
                if (idx === -1) {
                    res += encoder(userinfo, false);
                }
                else {
                    // <user>:<pass>@<auth>
                    res += encoder(userinfo.substr(0, idx), false);
                    res += ':';
                    res += encoder(userinfo.substr(idx + 1), false);
                }
                res += '@';
            }
            authority = authority.toLowerCase();
            idx = authority.indexOf(':');
            if (idx === -1) {
                res += encoder(authority, false);
            }
            else {
                // <auth>:<port>
                res += encoder(authority.substr(0, idx), false);
                res += authority.substr(idx);
            }
        }
        if (path) {
            // lower-case windows drive letters in /C:/fff or C:/fff
            if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) {
                var code = path.charCodeAt(1);
                if (code >= 65 /* A */ && code <= 90 /* Z */) {
                    path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3
                }
            }
            else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) {
                var code = path.charCodeAt(0);
                if (code >= 65 /* A */ && code <= 90 /* Z */) {
                    path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3
                }
            }
            // encode the rest of the path
            res += encoder(path, true);
        }
        if (query) {
            res += '?';
            res += encoder(query, false);
        }
        if (fragment) {
            res += '#';
            res += encoder(fragment, false);
        }
        return res;
    }
/**
     * Create the external version of a uri
     */
Create the external version of a uri
Create the external version of a uri
function _asFormatted(uri, skipEncoding) {
        var encoder = !skipEncoding
            ? encodeURIComponentFast
            : encodeURIComponentMinimal;
        var res = '';
        var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
        if (scheme) {
            res += scheme;
            res += ':';
        }
        if (authority || scheme === 'file') {
            res += _slash;
            res += _slash;
        }
        if (authority) {
            var idx = authority.indexOf('@');
            if (idx !== -1) {
                var userinfo = authority.substr(0, idx);
                authority = authority.substr(idx + 1);
                idx = userinfo.indexOf(':');
                if (idx === -1) {
                    res += encoder(userinfo, false);
                }
                else {
                    res += encoder(userinfo.substr(0, idx), false);
                    res += ':';
                    res += encoder(userinfo.substr(idx + 1), false);
                }
                res += '@';
            }
            authority = authority.toLowerCase();
            idx = authority.indexOf(':');
            if (idx === -1) {
                res += encoder(authority, false);
            }
            else {
                res += encoder(authority.substr(0, idx), false);
                res += authority.substr(idx);
            }
        }
        if (path) {
            if (path.length >= 3 && path.charCodeAt(0) === 47  && path.charCodeAt(2) === 58 ) {
                var code = path.charCodeAt(1);
                if (code >= 65  && code <= 90 ) {
                    path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); 
                }
            }
            else if (path.length >= 2 && path.charCodeAt(1) === 58 ) {
                var code = path.charCodeAt(0);
                if (code >= 65  && code <= 90 ) {
                    path = String.fromCharCode(code + 32) + ":" + path.substr(2); 
                }
            }
            res += encoder(path, true);
        }
        if (query) {
            res += '?';
            res += encoder(query, false);
        }
        if (fragment) {
            res += '#';
            res += encoder(fragment, false);
        }
        return res;
    }
function _asFormatted ( uri , skipEncoding ) { var encoder = ! skipEncoding ? encodeURIComponentFast : encodeURIComponentMinimal ; var res = '' ; var scheme = uri . scheme , authority = uri . authority , path = uri . path , query = uri . query , fragment = uri . fragment ; if ( scheme ) { res += scheme ; res += ':' ; } if ( authority || scheme === 'file' ) { res += _slash ; res += _slash ; } if ( authority ) { var idx = authority . indexOf ( '@' ) ; if ( idx !== - 1 ) { var userinfo = authority . substr ( 0 , idx ) ; authority = authority . substr ( idx + 1 ) ; idx = userinfo . indexOf ( ':' ) ; if ( idx === - 1 ) { res += encoder ( userinfo , false ) ; } else { res += encoder ( userinfo . substr ( 0 , idx ) , false ) ; res += ':' ; res += encoder ( userinfo . substr ( idx + 1 ) , false ) ; } res += '@' ; } authority = authority . toLowerCase ( ) ; idx = authority . indexOf ( ':' ) ; if ( idx === - 1 ) { res += encoder ( authority , false ) ; } else { res += encoder ( authority . substr ( 0 , idx ) , false ) ; res += authority . substr ( idx ) ; } } if ( path ) { if ( path . length >= 3 && path . charCodeAt ( 0 ) === 47 && path . charCodeAt ( 2 ) === 58 ) { var code = path . charCodeAt ( 1 ) ; if ( code >= 65 && code <= 90 ) { path = "/" + String . fromCharCode ( code + 32 ) + ":" + path . substr ( 3 ) ; } } else if ( path . length >= 2 && path . charCodeAt ( 1 ) === 58 ) { var code = path . charCodeAt ( 0 ) ; if ( code >= 65 && code <= 90 ) { path = String . fromCharCode ( code + 32 ) + ":" + path . substr ( 2 ) ; } } res += encoder ( path , true ) ; } if ( query ) { res += '?' ; res += encoder ( query , false ) ; } if ( fragment ) { res += '#' ; res += encoder ( fragment , false ) ; } return res ; }
Create the external version of a uri
Create the external version of a uri
// <user>@<auth> // <user>:<pass>@<auth> // <auth>:<port> // lower-case windows drive letters in /C:/fff or C:/fff /* Slash */ /* Colon */ /* A */ /* Z */ // "/c:".length === 3 /* Colon */ /* A */ /* Z */ // "/c:".length === 3 // encode the rest of the path