Unverified Commit 5c59feb7 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure resolvedPathname normalizes trailing slash (#81265)

Fixes case with trailing slash from refactoring done in
https://github.com/vercel/next.js/pull/81144
parent 45a5405d
......@@ -225,7 +225,9 @@ export async function handler(
const method = req.method || 'GET'
const resolvedUrl = formatUrl({
pathname: parsedUrl.pathname,
pathname: nextConfig.trailingSlash
? parsedUrl.pathname
: removeTrailingSlash(parsedUrl.pathname || '/'),
// make sure to only add query values from original URL
query: hasStaticProps ? {} : originalQuery,
})
......
......@@ -59,6 +59,7 @@ import {
type RouterServerContext,
} from '../lib/router-utils/router-server-context'
import { decodePathParams } from '../lib/router-utils/decode-path-params'
import { removeTrailingSlash } from '../../shared/lib/router/utils/remove-trailing-slash'
/**
* RouteModuleOptions is the options that are passed to the route module, other
......@@ -782,6 +783,8 @@ export abstract class RouteModule<
resolvedPathname = decodePathParams(resolvedPathname)
} catch (_) {}
resolvedPathname = removeTrailingSlash(resolvedPathname)
return {
query,
originalQuery,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment