ilib
Version:
iLib is a cross-engine library of internationalization (i18n) classes written in pure JS
1 lines • 1.09 kB
JavaScript
var Path={dirname:function(pathname){return pathname&&("."===(pathname=Path.normalize(pathname))?"..":Path.normalize(pathname+"/.."))},normalize:function(pathname){return pathname=pathname&&0===(pathname=1<(pathname=(pathname=(pathname=(pathname=(pathname=(pathname=(pathname=(pathname=(pathname=(pathname=pathname.replace(/\\/g,"/")).replace(/\/\//g,"/")).replace(/\/\//g,"/")).replace(/\/[^/]*[^\./]\/\.\./g,"/.")).replace(/^[^/]*[^\./]\/\.\./g,".")).replace(/\/\.\//g,"/")).replace(/^\.\//,"")).replace(/\/\//g,"/")).replace(/\/\.$/,"")).replace(/\/\//g,"/")).length?pathname.replace(/\/$/,""):pathname).length?".":pathname},join:function(var_args){for(var arr=[],i=0;i<arguments.length;i++)arr.push(arguments[i]&&0<arguments[i].length?arguments[i]:".");return Path.normalize(arr.join("/"))},basename:function(pathname,extension){var base=pathname,slash=pathname.lastIndexOf("/");return-1!==slash&&(base=pathname.substring(slash+1)),base=extension&&(pathname="."===extension[0]?extension:"."+extension,-1<(slash=base.lastIndexOf(pathname)))?base.substring(0,slash):base}};module.exports=Path;