On this page

    M

    path.isAbsolute

    History
    path.isAbsolute(path): boolean
    Attributes
    path:string
    Returns:boolean

    The path.isAbsolute() method determines if the literal path is absolute. Therefore, it’s not safe for mitigating path traversals.

    If the given path is a zero-length string, false will be returned.

    For example, on POSIX:

    path.isAbsolute('/foo/bar');   // true
    path.isAbsolute('/baz/..');    // true
    path.isAbsolute('/baz/../..'); // true
    path.isAbsolute('qux/');       // false
    path.isAbsolute('.');          // false

    On Windows:

    path.isAbsolute('//server');    // true
    path.isAbsolute('\\\\server');  // true
    path.isAbsolute('C:/foo/..');   // true
    path.isAbsolute('C:\\foo\\..'); // true
    path.isAbsolute('bar\\baz');    // false
    path.isAbsolute('bar/baz');     // false
    path.isAbsolute('.');           // false

    A TypeError is thrown if path is not a string.