history.js
function parseURL(href, isWindowLocation, isNotAPI) {
    var re = /(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/;
    if (href != null && href !== '' && !isWindowLocation) {
      var current = parseURL(),
          base = document.getElementsByTagName('base')[0];
      if (!isNotAPI && base && base.getAttribute('href')) {
        // Fix for IE ignoring relative base tags.
        // See http://stackoverflow.com/questions/3926197/html-base-tag-and-local-folder-path-with-internet-explorer
        base.href = base.href;
        current = parseURL(base.href, null, true);
      }
      var _pathname = current._pathname, _protocol = current._protocol;
      // convert to type of string
      href = '' + href;
      // convert relative link to the absolute
      href = /^(?:\w+\:)?\/\//.test(href) ? href.indexOf("/") === 0
        ? _protocol + href : href : _protocol + "//" + current._host + (
        href.indexOf("/") === 0 ? href : href.indexOf("?") === 0
          ? _pathname + href : href.indexOf("#") === 0
          ? _pathname + current._search + href : _pathname.replace(/[^\/]+$/g, '') + href
        );
    } else {
      href = isWindowLocation ? href : windowLocation.href;
      // if current browser not support History-API
      if (!isSupportHistoryAPI || isNotAPI) {
        // get hash fragment
        href = href.replace(/^[^#]*/, '') || "#";
        // form the absolute link from the hash
        // https://github.com/devote/HTML5-History-API/issues/50
        href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath']
          + href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), "");
      }
    }
    // that would get rid of the links of the form: /../../
    anchorElement.href = href;
    // decompose the link in parts
    var result = re.exec(anchorElement.href);
    // host name with the port number
    var host = result[2] + (result[3] ? ':' + result[3] : '');
    // folder
    var pathname = result[4] || '/';
    // the query string
    var search = result[5] || '';
    // hash
    var hash = result[6] === '#' ? '' : (result[6] || '');
    // relative link, no protocol, no host
    var relative = pathname + search + hash;
    // special links for set to hash-link, if browser not support History API
    var nohash = pathname.replace(new RegExp("^" + settings["basepath"], "i"), settings["type"]) + search;
    // result
    return {
      _href: result[1] + '//' + host + relative,
      _protocol: result[1],
      _host: host,
      _hostname: result[2],
      _port: result[3] || '',
      _pathname: pathname,
      _search: search,
      _hash: hash,
      _relative: relative,
      _nohash: nohash,
      _special: nohash + hash
    }
  }
function parseURL(href, isWindowLocation, isNotAPI) {
    var re = /(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/;
    if (href != null && href !== '' && !isWindowLocation) {
      var current = parseURL(),
          base = document.getElementsByTagName('base')[0];
      if (!isNotAPI && base && base.getAttribute('href')) {
        // Fix for IE ignoring relative base tags.
        // See http://stackoverflow.com/questions/3926197/html-base-tag-and-local-folder-path-with-internet-explorer
        base.href = base.href;
        current = parseURL(base.href, null, true);
      }
      var _pathname = current._pathname, _protocol = current._protocol;
      // convert to type of string
      href = '' + href;
      // convert relative link to the absolute
      href = /^(?:\w+\:)?\/\//.test(href) ? href.indexOf("/") === 0
        ? _protocol + href : href : _protocol + "//" + current._host + (
        href.indexOf("/") === 0 ? href : href.indexOf("?") === 0
          ? _pathname + href : href.indexOf("#") === 0
          ? _pathname + current._search + href : _pathname.replace(/[^\/]+$/g, '') + href
        );
    } else {
      href = isWindowLocation ? href : windowLocation.href;
      // if current browser not support History-API
      if (!isSupportHistoryAPI || isNotAPI) {
        // get hash fragment
        href = href.replace(/^[^#]*/, '') || "#";
        // form the absolute link from the hash
        // https://github.com/devote/HTML5-History-API/issues/50
        href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath']
          + href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), "");
      }
    }
    // that would get rid of the links of the form: /../../
    anchorElement.href = href;
    // decompose the link in parts
    var result = re.exec(anchorElement.href);
    // host name with the port number
    var host = result[2] + (result[3] ? ':' + result[3] : '');
    // folder
    var pathname = result[4] || '/';
    // the query string
    var search = result[5] || '';
    // hash
    var hash = result[6] === '#' ? '' : (result[6] || '');
    // relative link, no protocol, no host
    var relative = pathname + search + hash;
    // special links for set to hash-link, if browser not support History API
    var nohash = pathname.replace(new RegExp("^" + settings["basepath"], "i"), settings["type"]) + search;
    // result
    return {
      _href: result[1] + '//' + host + relative,
      _protocol: result[1],
      _host: host,
      _hostname: result[2],
      _port: result[3] || '',
      _pathname: pathname,
      _search: search,
      _hash: hash,
      _relative: relative,
      _nohash: nohash,
      _special: nohash + hash
    }
  }
function parseURL ( href , isWindowLocation , isNotAPI ) { var re = / (?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))? / ; if ( href != null && href !== '' && ! isWindowLocation ) { var current = parseURL ( ) , base = document . getElementsByTagName ( 'base' ) [ 0 ] ; if ( ! isNotAPI && base && base . getAttribute ( 'href' ) ) { // Fix for IE ignoring relative base tags. // See http://stackoverflow.com/questions/3926197/html-base-tag-and-local-folder-path-with-internet-explorer base . href = base . href ; current = parseURL ( base . href , null , true ) ; } var _pathname = current . _pathname , _protocol = current . _protocol ; // convert to type of string href = '' + href ; // convert relative link to the absolute href = / ^(?:\w+\:)?\/\/ / . test ( href ) ? href . indexOf ( "/" ) === 0 ? _protocol + href : href : _protocol + "//" + current . _host + ( href . indexOf ( "/" ) === 0 ? href : href . indexOf ( "?" ) === 0 ? _pathname + href : href . indexOf ( "#" ) === 0 ? _pathname + current . _search + href : _pathname . replace ( / [^\/]+$ / g , '' ) + href ) ; } else { href = isWindowLocation ? href : windowLocation . href ; // if current browser not support History-API if ( ! isSupportHistoryAPI || isNotAPI ) { // get hash fragment href = href . replace ( / ^[^#]* / , '' ) || "#" ; // form the absolute link from the hash // https://github.com/devote/HTML5-History-API/issues/50 href = windowLocation . protocol . replace ( / :.*$|$ / , ':' ) + '//' + windowLocation . host + settings [ 'basepath' ] + href . replace ( new RegExp ( "^#[\/]?(?:" + settings [ "type" ] + ")?" ) , "" ) ; } } // that would get rid of the links of the form: /../../ anchorElement . href = href ; // decompose the link in parts var result = re . exec ( anchorElement . href ) ; // host name with the port number var host = result [ 2 ] + ( result [ 3 ] ? ':' + result [ 3 ] : '' ) ; // folder var pathname = result [ 4 ] || '/' ; // the query string var search = result [ 5 ] || '' ; // hash var hash = result [ 6 ] === '#' ? '' : ( result [ 6 ] || '' ) ; // relative link, no protocol, no host var relative = pathname + search + hash ; // special links for set to hash-link, if browser not support History API var nohash = pathname . replace ( new RegExp ( "^" + settings [ "basepath" ] , "i" ) , settings [ "type" ] ) + search ; // result return { _href : result [ 1 ] + '//' + host + relative , _protocol : result [ 1 ] , _host : host , _hostname : result [ 2 ] , _port : result [ 3 ] || '' , _pathname : pathname , _search : search , _hash : hash , _relative : relative , _nohash : nohash , _special : nohash + hash } }
Prepares a parts of the current or specified reference for later use in the library

@param {string} [href]
@param {boolean} [isWindowLocation]
@param {boolean} [isNotAPI]
@return {Object}
Prepares a parts of the current or specified reference for later use in the library