Path Class
地址操作工具类
Item Index
Methods
basename
(
String
static
-
path
-
ext
获取域名中的文件名
Returns:
String:
返回结果字符串
Example:
Path.basename('http://www.taobao.com/index.html','.html');//=> index
dirname
(
String
static
-
path
返回path所指的文件所在的目录路径
Parameters:
-
path
String路径字符串
Returns:
Example:
Path.dirname('/home/bachi/daily/index.html');//=>/home/bachi/daily
extname
(
String
static
-
path
获取路径所指文件的扩展名,比如.html
Parameters:
-
path
String路径字符串
Returns:
Example:
Path.extname('/home/bachi/daily/index.html');//=> .html
normalize
(
String
static
-
path
将path中的无关内容清理掉,返回直接的路径信息
Parameters:
-
path
String路径字符串
Returns:
Example:
Path.normalize('x/y/../z'); // => x/z/
Path.normalize('x/y/z/../'); // => x/y/
relative
(
String
static
-
from
-
to
计算相对路径
Returns:
Example:
Path.relative('x/','x/y/z'); // => 'y/z'
Path.relative('x/t/z','x/'); // => '../../'
resolve
()
static
得到绝对地址,算法逻辑参照 NodeJS
Example:
Path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
// => 'wwwroot/static_files/gif/image.gif'
Path.resolve('/foo/bar', '/tmp/file/')
// => '/tmp/file'