test whether a given path is an absolute path (either windows or posix).

[!note] currently, we do consider the tilde expansion ("~") as an absolute path, even though it is not an os/fs-level path, but rather a shell feature. this may result in misclassification on windows, since "~" is a valid starting character for a file or folder name

import { assertEquals } from "jsr:@std/assert"

// aliasing our functions for brevity
const eq = assertEquals, fn = isAbsolutePath

eq(fn("/a/b/c.txt"), true)
eq(fn("~/a/b/c.txt"), true)
eq(fn("C:/a/b/c.txt"), true)
eq(fn("/c:/a/b/c.txt"), true)

eq(fn("a/b/c.txt"), false)
eq(fn("./a/b/c.txt"), false)
eq(fn("../a/b/c.txt"), false)