Skip to content

Function: isAbsolute() ​

ts
function isAbsolute(path): boolean;

Determine whether the given path string is an absolute path.

Parameters ​

ParameterTypeDescription
pathstringThe path string to be determined.

Returns ​

boolean

True if it's an absolute path, false otherwise.

Since ​

1.0.0

Example ​

ts
isAbsolute('/')      // => true
isAbsolute('/path')  // => true
isAbsolute('C:\\path')  // => true
isAbsolute('\\path')  // => true
isAbsolute('https://example.com')   // => true
isAbsolute('ftp://example.com')     // => true
isAbsolute('relative/path')  // => false

Released under the MIT License.