Skip to content

Commit

Permalink
fix: added extedned internal param removal
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh committed Aug 31, 2022
1 parent 13d87eb commit 7ad7b65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion packages/next/server/internal-utils.ts
Expand Up @@ -12,16 +12,27 @@ const INTERNAL_QUERY_NAMES = [
'__flight_router_state_tree__',
] as const

const EXTENDED_INTERNAL_QUERY_NAMES = ['__nextDataReq'] as const

export function stripInternalQueries(query: NextParsedUrlQuery) {
for (const name of INTERNAL_QUERY_NAMES) {
delete query[name]
}
}

export function stripInternalSearchParams(searchParams: URLSearchParams) {
export function stripInternalSearchParams(
searchParams: URLSearchParams,
extended?: boolean
) {
for (const name of INTERNAL_QUERY_NAMES) {
searchParams.delete(name)
}

if (extended) {
for (const name of EXTENDED_INTERNAL_QUERY_NAMES) {
searchParams.delete(name)
}
}

return searchParams
}
2 changes: 1 addition & 1 deletion packages/next/server/web/adapter.ts
Expand Up @@ -60,7 +60,7 @@ export async function adapter(params: {
requestUrl.flightData = undefined

// Strip internal query parameters off the request.
stripInternalSearchParams(requestUrl.searchParams)
stripInternalSearchParams(requestUrl.searchParams, true)

const request = new NextRequestHint({
page: params.page,
Expand Down

0 comments on commit 7ad7b65

Please sign in to comment.