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

    Function commonNormalizedPosixPath

    • find the prefix path directory common to all provided paths.

      Warning

      your paths MUST be normalized beforehand, and use posix dir-separators ("/").

      Parameters

      • paths: string[]

      Returns string

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

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

      eq(fn([
      "C:/Hello/World/This/Is/An/Example/Bla.cs",
      "C:/Hello/World/This/Is/Not/An/Example/",
      "C:/Hello/Earth/Bla/Bla/Bla",
      ]), "C:/Hello/")

      eq(fn([
      "C:/Hello/World/This/Is/An/Example/Bla.cs",
      "C:/Hello/World/This/is/an/example/bla.cs",
      "C:/Hello/World/This/Is/Not/An/Example/",
      ]), "C:/Hello/World/This/")

      eq(fn([
      "./../Hello/World/Users/This/Is/An/Example/Bla.cs",
      "./../Hello/World Users/This/Is/An/example/bla.cs",
      "./../Hello/World-Users/This/Is/Not/An/Example/",
      ]), "./../Hello/")

      eq(fn([
      "./Hello/World/Users/This/Is/An/Example/Bla.cs",
      "./Hello/World/",
      "./Hello/World", // the "World" here segment is not treated as a directory
      ]), "./Hello/")

      eq(fn([
      "C:/Hello/World/",
      "/C:/Hello/World/",
      "C:/Hello/World/",
      ]), "") // no common prefix was identified