UNPKG

486 BJavaScriptView Raw
1var join = require('../array/join');
2var slice = require('../array/slice');
3
4 /**
5 * Group arguments as path segments, if any of the args is `null` or an
6 * empty string it will be ignored from resulting path.
7 */
8 function makePath(var_args){
9 var result = join(slice(arguments), '/');
10 // need to disconsider duplicate '/' after protocol (eg: 'http://')
11 return result.replace(/([^:\/]|^)\/{2,}/g, '$1/');
12 }
13
14 module.exports = makePath;
15