有没快捷的方式可以获取多个文件路径的共同根路径,如下:
let file1 = '/a/b/c.txt';
let file2 = '/a/b/d.txt';
let file3 = '/a/e';
let file4 = '/f/e';
console.log(getCommonPath(file1, file2, file3)); // '/a/';
console.log(getCommonPath(file1, file2)); // '/a/b/';
console.log(getCommonPath(file1)); // '/a/b/';
console.log(getCommonPath(file1, file4)); // '/';
最长公共前缀