dist/crocodoc.viewer.js
function (url) {
            var parsed = document.createElement('a'),
                pathname;

            parsed.href = url;

            // @NOTE: IE does not automatically parse relative urls,
            // but requesting href back from the <a> element will return
            // an absolute URL, which can then be fed back in to get the
            // expected result. WTF? Yep!
            if (browser.ie && url !== parsed.href) {
                url = parsed.href;
                parsed.href = url;
            }

            // @NOTE: IE does not include the preceding '/' in pathname
            pathname = parsed.pathname;
            if (!/^\//.test(pathname)) {
                pathname = '/' + pathname;
            }

            return {
                href: parsed.href,
                protocol: parsed.protocol, // includes :
                host: parsed.host, // includes port
                hostname: parsed.hostname, // does not include port
                port: parsed.port,
                pathname: pathname,
                hash: parsed.hash,  // inclues #
                search: parsed.search // incudes ?
            };
        }
function (url) {
            var parsed = document.createElement('a'),
                pathname;

            parsed.href = url;

            // @NOTE: IE does not automatically parse relative urls,
            // but requesting href back from the <a> element will return
            // an absolute URL, which can then be fed back in to get the
            // expected result. WTF? Yep!
            if (browser.ie && url !== parsed.href) {
                url = parsed.href;
                parsed.href = url;
            }

            // @NOTE: IE does not include the preceding '/' in pathname
            pathname = parsed.pathname;
            if (!/^\//.test(pathname)) {
                pathname = '/' + pathname;
            }

            return {
                href: parsed.href,
                protocol: parsed.protocol, // includes :
                host: parsed.host, // includes port
                hostname: parsed.hostname, // does not include port
                port: parsed.port,
                pathname: pathname,
                hash: parsed.hash,  // inclues #
                search: parsed.search // incudes ?
            };
        }
function ( url ) { var parsed = document . createElement ( 'a' ) , pathname ; parsed . href = url ; // @NOTE: IE does not automatically parse relative urls, // but requesting href back from the <a> element will return // an absolute URL, which can then be fed back in to get the // expected result. WTF? Yep! if ( browser . ie && url !== parsed . href ) { url = parsed . href ; parsed . href = url ; } // @NOTE: IE does not include the preceding '/' in pathname pathname = parsed . pathname ; if ( ! / ^\/ / . test ( pathname ) ) { pathname = '/' + pathname ; } return { href : parsed . href , protocol : parsed . protocol , // includes : host : parsed . host , // includes port hostname : parsed . hostname , // does not include port port : parsed . port , pathname : pathname , hash : parsed . hash , // inclues # search : parsed . search // incudes ? } ; }
Parse a URL into protocol, host, port, etc
@param   {string} url The URL to parse
@returns {object}     The parsed URL parts
Parse a URL into protocol host port etc