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( ...@@ -225,7 +225,9 @@ export async function handler(
const method = req.method || 'GET' const method = req.method || 'GET'
const resolvedUrl = formatUrl({ const resolvedUrl = formatUrl({
pathname: parsedUrl.pathname, pathname: nextConfig.trailingSlash
? parsedUrl.pathname
: removeTrailingSlash(parsedUrl.pathname || '/'),
// make sure to only add query values from original URL // make sure to only add query values from original URL
query: hasStaticProps ? {} : originalQuery, query: hasStaticProps ? {} : originalQuery,
}) })
......
...@@ -59,6 +59,7 @@ import { ...@@ -59,6 +59,7 @@ import {
type RouterServerContext, type RouterServerContext,
} from '../lib/router-utils/router-server-context' } from '../lib/router-utils/router-server-context'
import { decodePathParams } from '../lib/router-utils/decode-path-params' 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 * RouteModuleOptions is the options that are passed to the route module, other
...@@ -782,6 +783,8 @@ export abstract class RouteModule< ...@@ -782,6 +783,8 @@ export abstract class RouteModule<
resolvedPathname = decodePathParams(resolvedPathname) resolvedPathname = decodePathParams(resolvedPathname)
} catch (_) {} } catch (_) {}
resolvedPathname = removeTrailingSlash(resolvedPathname)
return { return {
query, query,
originalQuery, 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