// Copyright 2018-2026 the Deno authors. MIT license. // This module is browser compatible. import { isWindows } from "../internal/os.ts"; import { isAbsolute as posixIsAbsolute } from "./posix/is_absolute.ts"; import { isAbsolute as windowsIsAbsolute } from "./windows/is_absolute.ts"; /** * Verifies whether provided path is absolute. * * @example Usage * ```ts * import { isAbsolute } from "is_absolute.ts"; * import { assert, assertFalse } from "../assert/mod.ts"; * * if (Deno.build.os === "windows") { * assert(isAbsolute("C:\\home\\foo")); * assertFalse(isAbsolute("home\\foo")); * } else { * assert(isAbsolute("/home/foo")); * assertFalse(isAbsolute("home/foo")); * } * ``` * * @param path Path to be verified as absolute. * @returns `true` if path is absolute, `false` otherwise */ export function isAbsolute(path: string): boolean { return isWindows ? windowsIsAbsolute(path) : posixIsAbsolute(path); }