Multiple slashes in the end of string URL

The user entered multiple slashes (/) at the end of the URL. How do I fix this? I tried middleware, but it either causes multiple redirects or doesn't change anything—the browser also shows multiple slashes at the end of the URL.

Reverse proxies usually don't handle user errors. Maybe you share what you have tried.

I tryed this solutioon

http:
  middlewares:
    slashes:
      chain:
        middlewares:
          - merge-slashes
          - merge-slashes-full   
   # remove multi slash from url    
   merge-slashes-full:
     redirectRegex:
     regex: "([^:])//+"
     replacement: "${1}/"
     permanent: true # Optional: set to true for a permanent redirect

   # remove multi slash only from path
   merge-slashes:
     replacePathRegex:
     regex: "//+$"
     replacement: "/"

merge-slashes-full - remove slashes in middle URL, but this work only if in the end url - no slash ))

merge-slashes - i tryed remove slash in the end. If replacement: “/” - this not work. If replacement: “” - many redirects.