purge the common path among all provided paths, and replace (join) it with a new_common_dir path.

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

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

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",
], "D:/"), [
"D:/World/This/Is/An/Example/Bla.cs",
"D:/World/This/Is/Not/An/Example/",
"D:/Earth/Bla/Bla/Bla",
])
eq(fn([
"C:/Hello/World/This/Used/to-be-an/example/../../../Is/An/Example/Bla.cs",
"C:/Hello/World/This/Is/an/example/bla.cs",
"C:/Hello/World/This/Is/Not/An/Example/",
], "D:/temp"), [ // an implicit forward slash is added.
"D:/temp/An/Example/Bla.cs",
"D:/temp/an/example/bla.cs",
"D:/temp/Not/An/Example/",
])
eq(fn([
// there is no common ancestor among each of the paths (even "C:/" and "./C:/" are not considered to be equivalent to one another)
"http:/Hello/World.cs",
"./C:/Hello/World.cs",
"C:/Hello/World/file.cs",
], "D:/temp/"), [
"D:/temp/http:/Hello/World.cs",
"D:/temp/C:/Hello/World.cs",
"D:/temp/C:/Hello/World/file.cs",
])
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-Users/./././././This/Is/Not/An/Example/",
], "file:///./.\\HELLO.\\./../"), [ // the `new_common_dir` is not normalized by this function
"file:///./.\\HELLO.\\./..///World/Users/This/Is/An/Example/Bla.cs",
"file:///./.\\HELLO.\\./../World Users/This/Is/An/example/bla.cs",
"file:///./.\\HELLO.\\./../World-Users/This/Is/Not/An/Example/",
])