Function commonNormalizedPosixPath

find the prefix path directory common to all provided paths.

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

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