1 export var resolvePath = function (...paths: string[]): string {
3 function resolve(pathA, pathB) {
6 // '/a/b' => ['', 'a', 'b']
7 // '/a/b/' => ['', 'a', 'b', '']
8 pathB = pathB.split('/');
10 return pathB.join('/');
12 pathA = pathA.split('/');
13 var aLastIndex = pathA.length - 1;
14 if (pathA[aLastIndex] !== '') {
15 pathA[aLastIndex] = '';
20 while (typeof (part = pathB[i]) === 'string') {
39 if (pathB[pathB.length - 1] !== '') pathA.pop();
40 return pathA.join('/');
45 var r = location.pathname;
47 const urlRegex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i;
48 const multiSlashReg = /\/\/+/g;
50 while (typeof (path = paths[i]) === 'string') {
52 const matches = path && path.match(urlRegex);
56 path = path.replace(multiSlashReg, '/');