docs: function parseIndex(arg) {
      assert.optionalString(arg, 'arg');
  
      var index = {};
  
      if (!arg || arg === DEFAULT_LOGIN_SERVERNAME) {
          // Default index.
          index.name = DEFAULT_INDEX_NAME;
          index.official = true;
      } else {
          // Optional protocol/scheme.
          var indexName;
          var protoSepIdx = arg.indexOf('://');
          if (protoSepIdx !== -1) {
              var scheme = arg.slice(0, protoSepIdx);
              if (['http', 'https'].indexOf(scheme) === -1) {
                  throw new Error('invalid index scheme, must be ' +
                      '"http" or "https": ' + arg);
              }
              index.scheme = scheme;
              indexName = arg.slice(protoSepIdx + 3);
          } else {
              indexName = arg;
          }
  
          if (!indexName) {
              throw new Error('invalid index, empty host: ' + arg);
          } else if (indexName.indexOf('.') === -1 &&
              indexName.indexOf(':') === -1 &&
              indexName !== 'localhost')
          {
              throw new Error(fmt('invalid index, "%s" does not look like a ' +
                  'valid host: %s', indexName, arg));
          } else {
              // Allow a trailing '/' as from some URL builder functions that
              // add a default '/' path to a URL, e.g. 'https://docker.io/'.
              if (indexName[indexName.length - 1] === '/') {
                  indexName = indexName.slice(0, indexName.length - 1);
              }
  
              // Ensure no trailing repo.
              if (indexName.indexOf('/') !== -1) {
                  throw new Error('invalid index, trailing repo: ' + arg);
              }
          }
  
          // Per docker.git's `ValidateIndexName`.
          if (indexName === 'index.' + DEFAULT_INDEX_NAME) {
              indexName = DEFAULT_INDEX_NAME;
          }
  
          index.name = indexName;
          index.official = Boolean(indexName === DEFAULT_INDEX_NAME);
      }
  
      // Disallow official and 'http'.
      if (index.official && index.scheme === 'http') {
          throw new Error('invalid index, HTTP to official index ' +
              'is disallowed: ' + arg);
      }
  
      return index;
  }