trim the trailing forward-slashes at the end of a string, except for those that are preceded by a dotslash ("/./") or a dotdotslash ("/../")

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

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

eq(fn("///a/b.zip///"), "///a/b.zip")
eq(fn("///a/b.zip/.///"), "///a/b.zip/./")
eq(fn("///a/b.zip/..///"), "///a/b.zip/../")
eq(fn("///a/b.zip/...///"), "///a/b.zip/...")
eq(fn("///a/b.zip/wut.///"), "///a/b.zip/wut.")
eq(fn("///a/b.zip/wut..///"), "///a/b.zip/wut..")
eq(fn("///a/b.zip/wut...///"), "///a/b.zip/wut...")
eq(fn(".///../a/b.zip/"), ".///../a/b.zip")
eq(fn("file:///a/b.zip//c.txt"), "file:///a/b.zip//c.txt")