Method description:
Check whether path is an absolute path. An absolute path will resolve to the same location whether in the working directory or not.
Grammar:
path.isAbsolute(path)
Since this method belongs to the path module, the path module needs to be introduced before use (var path= require(“path”) )
Receive parameters:
path path path
Example:
//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:
// 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;
};
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn