code: function extractUnescapedDirs(p) {
    var re = /\/|$/g;
    var m;
  
    var pathAccum = '';
    var pathElements = [];
  
    // It's always possible that the root is an app dir; the regex won't
    // catch that so we add it explicitly
    pathElements.unshift({path: '', rawPath: ''});
  
    var lastpos = 0;
    var element;
    while (m = re.exec(p)) {
      // This can happen if p ends with /, since we match on $
      if (lastpos > p.length)
        break;
      element = unescape(p.substring(lastpos, m.index));
      lastpos = m.index + 1;
  
      // empty? ignore.
      if (!element) {
        continue;
      }
      // only spaces? bail.
      if (/^\s*$/.test(element))
        return null;
      // ..? bail.
      if (element === '..')
        return null;
      if (element === '.')
        continue;
      // contains \ or / (possible if the / was escaped)? bail.
      if (/[\/\\]/.test(element))
        return null;
  
      if (pathAccum)
        pathAccum += path.sep;
      pathAccum += element;
  
      pathElements.push({path: pathAccum, rawPath: p.substring(0, m.index)});
    }
    return pathElements;
  }
docs: Convert the given /-delimited path into a list of dirs and its original
  representation in the escaped path. For example:
  
  Input: /foo/bar//./this%20that/blah
  Output: [
  { path: 'foo', rawPath: '/foo' },
  { path: 'foo/bar', rawPath: '/foo/bar' },
  { path: 'foo/bar/this that', rawPath: '/foo/bar//./this%20that' }
  
  If .. or escaped / is detected in any of the path elements then null is
  returned, indicating that the given path could not be safely mapped to
  a path.