3 var isRelative = require('is-relative');
4 var isWindows = require('is-windows');
10 module.exports = isAbsolute;
13 * Returns true if a file path is absolute.
15 * @param {String} `fp`
19 function isAbsolute(fp) {
20 if (typeof fp !== 'string') {
21 throw new TypeError('isAbsolute expects a string.');
23 return isWindows() ? isAbsolute.win32(fp) : isAbsolute.posix(fp);
30 isAbsolute.posix = function posixPath(fp) {
31 return fp.charAt(0) === '/';
38 isAbsolute.win32 = function win32(fp) {
39 if (/[a-z]/i.test(fp.charAt(0)) && fp.charAt(1) === ':' && fp.charAt(2) === '\\') {
42 // Microsoft Azure absolute filepath
43 if (fp.slice(0, 2) === '\\\\') {
46 return !isRelative(fp);