lib/utils.js
function parseName(value) {
  var jobParts = [];

  var pathParts = (urlParse(value).pathname || '').split('/').filter(Boolean);
  var state = 0;
  var part;

  // iterate until we find our first job, then collect the continuous job parts
  //   ['foo', 'job', 'a', 'job', 'b', 'bar', 'job', 'c'] => ['a', 'b']
  loop:
  for (var i = 0; i < pathParts.length; i++) {
    part = pathParts[i];

    switch (state) {
      case 0:
        if (part === 'job') state = 2;
        break;
      case 1:
        if (part !== 'job') break loop;
        state = 2;
        break;
      case 2:
        jobParts.push(part);
        state = 1;
        break;
    }
  }

  return jobParts.map(decodeURIComponent);
}
function parseName(value) {
  var jobParts = [];

  var pathParts = (urlParse(value).pathname || '').split('/').filter(Boolean);
  var state = 0;
  var part;

  // iterate until we find our first job, then collect the continuous job parts
  //   ['foo', 'job', 'a', 'job', 'b', 'bar', 'job', 'c'] => ['a', 'b']
  loop:
  for (var i = 0; i < pathParts.length; i++) {
    part = pathParts[i];

    switch (state) {
      case 0:
        if (part === 'job') state = 2;
        break;
      case 1:
        if (part !== 'job') break loop;
        state = 2;
        break;
      case 2:
        jobParts.push(part);
        state = 1;
        break;
    }
  }

  return jobParts.map(decodeURIComponent);
}
function parseName ( value ) { var jobParts = [ ] ; var pathParts = ( urlParse ( value ) . pathname || '' ) . split ( '/' ) . filter ( Boolean ) ; var state = 0 ; var part ; // iterate until we find our first job, then collect the continuous job parts //   ['foo', 'job', 'a', 'job', 'b', 'bar', 'job', 'c'] => ['a', 'b'] loop : for ( var i = 0 ; i < pathParts . length ; i ++ ) { part = pathParts [ i ] ; switch ( state ) { case 0 : if ( part === 'job' ) state = 2 ; break ; case 1 : if ( part !== 'job' ) break loop ; state = 2 ; break ; case 2 : jobParts . push ( part ) ; state = 1 ; break ; } } return jobParts . map ( decodeURIComponent ) ; }
Parse job name from URL
Parse job name from URL