Method description:
Detect whether the path is an absolute path. An absolute path will resolve to the same location, whether in the working directory or not.
grammar:
The code copy is as follows:
path.isAbsolute(path)
Since this method belongs to the path module, you need to introduce the path module before use (var path= require("path") )
Receive parameters:
path path path
example:
The code copy is as follows:
//Posix examples:
path.isAbsolute('/foo/bar') // true
path.isAbsolute('/baz/..') // true
path.isAbsolute('qux/') // false
path.isAbsolute('.') // false
//Windows examples:
path.isAbsolute('//server') // true
path.isAbsolute('C:/foo/..') // true
path.isAbsolute('bar//baz') // false
path.isAbsolute('.') // false
Source code:
The code copy is as follows:
// windows version
exports.isAbsolute = function(path) {
var result = splitDeviceRe.exec(path),
device = result[1] || '',
isUnc = device && device.charAt(1) !== ':';
// UNC paths are always absolute
return !!result[2] || isUnc;
};