trim leading and trailing forward-slashes ("/") and dot-slashes ("./"), at the beginning and end of a string, but keep trailing non-trivial ones intact. this is a combination of trimStartDotSlashes and trimEndDotSlashes, so see their doc comments for more precise test cases.

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

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

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("file:///a/b.zip//c.txt"), "file:///a/b.zip//c.txt")