@oazmi/kitchensink - v0.9.13
    Preparing search index...

    Function isAbsolutePath

    • 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

      Parameters

      • path: string

      Returns boolean

      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)