@oazmi/kitchensink - v0.9.13
    Preparing search index...

    Function trimEndSlashes

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

      Parameters

      • str: string

      Returns string

      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")