node_modules/vscode-fuzzy-scorer/dist/vscode_common/uri.js
/**
 * 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) {
  const encoder = !skipEncoding ? encodeURIComponentFast : encodeURIComponentMinimal;
  let res = '';
  const scheme = uri.scheme,
        query = uri.query,
        fragment = uri.fragment;
  let authority = uri.authority,
      path = uri.path;
  if (scheme) {
    res += scheme;
    res += ':';
  }
  if (authority || scheme === 'file') {
    res += _slash;
    res += _slash;
  }
  if (authority) {
    let idx = authority.indexOf('@');
    if (idx !== -1) {
      const 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) === _charCode.CharCode.Slash && path.charCodeAt(2) === _charCode.CharCode.Colon) {
      const code = path.charCodeAt(1);
      if (code >= _charCode.CharCode.A && code <= _charCode.CharCode.Z) {
        path = `/${String.fromCharCode(code + 32)}:${path.substr(3)}`; 
      }
    } else if (path.length >= 2 && path.charCodeAt(1) === _charCode.CharCode.Colon) {
      const code = path.charCodeAt(0);
      if (code >= _charCode.CharCode.A && code <= _charCode.CharCode.Z) {
        path = `${String.fromCharCode(code + 32)}:${path.substr(2)}`; 
      }
    } 
    res += encoder(path, true);
  }
  if (query) {
    res += '?';
    res += encoder(query, false);
  }
  if (fragment) {
    res += '#';
    res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
  }
  return res;
} 
function _asFormatted ( uri , skipEncoding ) { const encoder = ! skipEncoding ? encodeURIComponentFast : encodeURIComponentMinimal ; let res = '' ; const scheme = uri . scheme , query = uri . query , fragment = uri . fragment ; let authority = uri . authority , path = uri . path ; if ( scheme ) { res += scheme ; res += ':' ; } if ( authority || scheme === 'file' ) { res += _slash ; res += _slash ; } if ( authority ) { let idx = authority . indexOf ( '@' ) ; if ( idx !== - 1 ) { const 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 ) === _charCode . CharCode . Slash && path . charCodeAt ( 2 ) === _charCode . CharCode . Colon ) { const code = path . charCodeAt ( 1 ) ; if ( code >= _charCode . CharCode . A && code <= _charCode . CharCode . Z ) { path = ` ${ String . fromCharCode ( code + 32 ) } ${ path . substr ( 3 ) } ` ; } } else if ( path . length >= 2 && path . charCodeAt ( 1 ) === _charCode . CharCode . Colon ) { const code = path . charCodeAt ( 0 ) ; if ( code >= _charCode . CharCode . A && code <= _charCode . CharCode . Z ) { path = ` ${ String . fromCharCode ( code + 32 ) } ${ path . substr ( 2 ) } ` ; } } res += encoder ( path , true ) ; } if ( query ) { res += '?' ; res += encoder ( query , false ) ; } if ( fragment ) { res += '#' ; res += ! skipEncoding ? encodeURIComponentFast ( fragment , false ) : fragment ; } 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 // "/c:".length === 3 // "/c:".length === 3 // encode the rest of the path // --- decode