joins multiple path segments into a single normalized posix path, correctly handling files and directories differently when the "./" and "../" navigation commands are encountered.

for lots of other (posix-only) test cases, see the doc comments of joinPosixPaths.

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

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

eq(fn("C:\\", "a", "b", "c.zip"), "C:/a/b/c.zip")
eq(fn("a", "b", "c.zip"), "a/b/c.zip")
eq(fn("/a\\b\\", "c/"), "/a/b/c/")
eq(fn("a", "b", "c.zip", "./"), "a/b/")
eq(fn("a", "b", "c.zip", "../"), "a/")
eq(fn("a", "b", "c.zip", "./d.txt"), "a/b/d.txt")
eq(fn("a", "b", "c.zip", "../d.txt"), "a/d.txt")
eq(fn("a/b/c/", "..", "./", "d.txt"), "a/b/d.txt")
eq(fn("a/b/c/", "../", ".", "d.txt"), "a/b/d.txt")
eq(fn("a/b/c", "../", "./", "d.txt"), "a/d.txt")
eq(fn("file:", "\\\\", "a/b/c", "./d"), "file:///a/b/d")
eq(fn("file://\\", "a/b/c", "./d/"), "file:///a/b/d/")