diff --git a/packages/next-on-pages/templates/_worker.js/routes-matcher.ts b/packages/next-on-pages/templates/_worker.js/routes-matcher.ts index c00b22b7a..761db1856 100644 --- a/packages/next-on-pages/templates/_worker.js/routes-matcher.ts +++ b/packages/next-on-pages/templates/_worker.js/routes-matcher.ts @@ -361,6 +361,9 @@ export class RoutesMatcher { this.path = this.path.replace(/\.rsc/i, ''); } + // Prevent `//` in path names. + this.path = this.path.replace(/\/\//g, '/') + // Merge search params for later use when serving a response. const destUrl = new URL(this.path, this.url); applySearchParams(this.searchParams, destUrl.searchParams);