find the prefix path directory common to all provided paths. your input paths do not need to be normalized nor necessarily use posix-style separator "/". under the hood, this function normalizes and converts all paths to posix-style, then applies the commonNormalizedPosixPath onto them.

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

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

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([
"./Hello/World/This/Used/to-be-an/example/../../../Is/An/Example/Bla.cs",
".\\Hello/World/This/Is/an/example/bla.cs",
"./Hello/World/This/Is/Not/An/Example/",
]), "./Hello/World/This/Is/")
eq(fn([
"./../home/Hello/World/Users/This/Is/An/Example/Bla.cs",
"././../home\\Hello\\World Users\\This\\Is/An\\example/bla.cs",
"./../home/./.\\.\\././Hello/World-Users/./././././This/Is/Not/An/Example/",
]), "../home/Hello/")
eq(fn([
"\\C:/Hello/World/Users/This/Is/An/Example/Bla.cs",
"/C:\\Hello\\World Users\\This\\Is/An\\example/bla.cs",
"/C:/Hello/World", // the "World" here segment is not treated as a directory
]), "/C:/Hello/")