Multiple trailing slashes

Hi,

I’m wondering if (in a worker) it’s possible to detect and redirect the case where (for whatever weird reason) there are multiple trailing slashes on a base url.

I can successfully redirect:
mydomain.com/path/// -> mydomain.com/path
mydomain.com/path// -> mydomain.com/path
mydomain.com/path/ -> mydomain.com/path
mydomain.com/ -> mydomain.com

but I cannot detect and redirect
mydomain.com/// ->

Out of amusement I tried going to
https://www.cloudflare.com///

and got an error.

FetchEvent’s .request.url pathname is always ‘/’ in all cases.

Thanks!
Loren

How is your Worker mapped? As long as the mapping contains a wildcard it should receive the consecutive slashes just fine as well.

Indeed it does, right as I was falling asleep I realized that I’m effectively parsing away the rest of the trailing slashes because I’m doing new URL(request.url).pathname – I need to look at the actual request.url!

Dopey mistake! Thanks for the tip.

This topic was automatically closed 6 hours after the last reply. New replies are no longer allowed.