Multiple trailing slashes


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: -> -> -> ->

but I cannot detect and redirect ->

Out of amusement I tried going to

and got an error.

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


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.