lib/relpath.js
function longestCommonPathPrefix(stra, strb) {
  const minlen = min(stra.length, strb.length);
  let common = 0;
  let lastSep = -1;
  for (; common < minlen; ++common) {
    const chr = stra[common];
    if (chr !== strb[common]) {
      break;
    }
    if (chr === sep) {
      lastSep = common;
    }
  }
  if (common === minlen &&
      (stra.length === minlen ?
        strb.length === minlen || strb[minlen] === sep :
        stra[minlen] === sep)) {
    return minlen + 1;
  }
  return lastSep + 1;
}
function longestCommonPathPrefix(stra, strb) {
  const minlen = min(stra.length, strb.length);
  let common = 0;
  let lastSep = -1;
  for (; common < minlen; ++common) {
    const chr = stra[common];
    if (chr !== strb[common]) {
      break;
    }
    if (chr === sep) {
      lastSep = common;
    }
  }
  if (common === minlen &&
      (stra.length === minlen ?
        strb.length === minlen || strb[minlen] === sep :
        stra[minlen] === sep)) {
    return minlen + 1;
  }
  return lastSep + 1;
}
function longestCommonPathPrefix ( stra , strb ) { const minlen = min ( stra . length , strb . length ) ; let common = 0 ; let lastSep = - 1 ; for ( ; common < minlen ; ++ common ) { const chr = stra [ common ] ; if ( chr !== strb [ common ] ) { break ; } if ( chr === sep ) { lastSep = common ; } } if ( common === minlen && ( stra . length === minlen ? strb . length === minlen || strb [ minlen ] === sep : stra [ minlen ] === sep ) ) { return minlen + 1 ; } return lastSep + 1 ; }
Longest common prefix that ends on a path element boundary. Each input is assumed to end with an implicit path separator.
Longest common prefix that ends on a path element boundary . Each input is assumed to end with an implicit path separator .