trim leading and trailing forward-slashes, at the beginning and end of a string. this is a combination of trimStartSlashes and trimEndSlashes, so see their doc comments for more precise test cases.
import { assertEquals } from "jsr:@std/assert"// aliasing our functions for brevityconst eq = assertEquals, fn = trimSlasheseq(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/.//.///"), "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") Copy
import { assertEquals } from "jsr:@std/assert"// aliasing our functions for brevityconst eq = assertEquals, fn = trimSlasheseq(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/.//.///"), "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")
trim leading and trailing forward-slashes, at the beginning and end of a string. this is a combination of trimStartSlashes and trimEndSlashes, so see their doc comments for more precise test cases.
Example