index.js
function expand(str, opts) {
  opts = opts || {};

  if (typeof str !== 'string') {
    throw new TypeError('expand-object expects a string.');
  }

  if (!/[.|:=]/.test(str) && /,/.test(str)) {
    return toArray(str);
  }

  var m;
  if ((m = /(\w+[:=]\w+\.)+/.exec(str)) && !/[|,+]/.test(str)) {
    var val = m[0].split(':').join('.');
    str = val + str.slice(m[0].length);
  }

  var arr = splitString(str, '|');
  var len = arr.length, i = -1;
  var res = {};

  if (isArrayLike(str) && arr.length === 1) {
    return expandArrayObj(str, opts);
  }

  while (++i < len) {
    var val = arr[i];
    // test for `https://foo`
    if (/\w:\/\/\w/.test(val)) {
      res[val] = '';
      continue;
    }

    var re = /^((?:\w+)\.(?:\w+))[:.]((?:\w+,)+)+((?:\w+):(?:\w+))/;
    var m = re.exec(val);
    if (m && m[1] && m[2] && m[3]) {
      var arrVal = m[2];
      arrVal = arrVal.replace(/,$/, '');
      var prop = arrVal.split(',');
      prop = prop.concat(toObject(m[3]));
      res = set(res, m[1], prop);
    } else if (!/[.,\|:=]/.test(val)) {
      res[val] = opts.toBoolean ? true : '';
    } else {
      res = expandObject(res, val, opts);
    }
  }
  return res;
}
function expand(str, opts) {
  opts = opts || {};

  if (typeof str !== 'string') {
    throw new TypeError('expand-object expects a string.');
  }

  if (!/[.|:=]/.test(str) && /,/.test(str)) {
    return toArray(str);
  }

  var m;
  if ((m = /(\w+[:=]\w+\.)+/.exec(str)) && !/[|,+]/.test(str)) {
    var val = m[0].split(':').join('.');
    str = val + str.slice(m[0].length);
  }

  var arr = splitString(str, '|');
  var len = arr.length, i = -1;
  var res = {};

  if (isArrayLike(str) && arr.length === 1) {
    return expandArrayObj(str, opts);
  }

  while (++i < len) {
    var val = arr[i];
    // test for `https://foo`
    if (/\w:\/\/\w/.test(val)) {
      res[val] = '';
      continue;
    }

    var re = /^((?:\w+)\.(?:\w+))[:.]((?:\w+,)+)+((?:\w+):(?:\w+))/;
    var m = re.exec(val);
    if (m && m[1] && m[2] && m[3]) {
      var arrVal = m[2];
      arrVal = arrVal.replace(/,$/, '');
      var prop = arrVal.split(',');
      prop = prop.concat(toObject(m[3]));
      res = set(res, m[1], prop);
    } else if (!/[.,\|:=]/.test(val)) {
      res[val] = opts.toBoolean ? true : '';
    } else {
      res = expandObject(res, val, opts);
    }
  }
  return res;
}
function expand ( str , opts ) { opts = opts || { } ; if ( typeof str !== 'string' ) { throw new TypeError ( 'expand-object expects a string.' ) ; } if ( ! / [.|:=] / . test ( str ) && / , / . test ( str ) ) { return toArray ( str ) ; } var m ; if ( ( m = / (\w+[:=]\w+\.)+ / . exec ( str ) ) && ! / [|,+] / . test ( str ) ) { var val = m [ 0 ] . split ( ':' ) . join ( '.' ) ; str = val + str . slice ( m [ 0 ] . length ) ; } var arr = splitString ( str , '|' ) ; var len = arr . length , i = - 1 ; var res = { } ; if ( isArrayLike ( str ) && arr . length === 1 ) { return expandArrayObj ( str , opts ) ; } while ( ++ i < len ) { var val = arr [ i ] ; // test for `https://foo` if ( / \w:\/\/\w / . test ( val ) ) { res [ val ] = '' ; continue ; } var re = / ^((?:\w+)\.(?:\w+))[:.]((?:\w+,)+)+((?:\w+):(?:\w+)) / ; var m = re . exec ( val ) ; if ( m && m [ 1 ] && m [ 2 ] && m [ 3 ] ) { var arrVal = m [ 2 ] ; arrVal = arrVal . replace ( / ,$ / , '' ) ; var prop = arrVal . split ( ',' ) ; prop = prop . concat ( toObject ( m [ 3 ] ) ) ; res = set ( res , m [ 1 ] , prop ) ; } else if ( ! / [.,\|:=] / . test ( val ) ) { res [ val ] = opts . toBoolean ? true : '' ; } else { res = expandObject ( res , val , opts ) ; } } return res ; }
Expand the given string into an object.

@param  {String} `str`
@return {Object}
Expand the given string into an object .