33a6dca747
This masks flight parameters from middleware so it doesn't interfere with RSC or routing. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
38 lines
812 B
TypeScript
38 lines
812 B
TypeScript
import type { NextParsedUrlQuery } from './request-meta'
|
|
|
|
const INTERNAL_QUERY_NAMES = [
|
|
'__nextFallback',
|
|
'__nextLocale',
|
|
'__nextDefaultLocale',
|
|
'__nextIsNotFound',
|
|
// RSC
|
|
'__flight__',
|
|
// Routing
|
|
'__flight_router_state_tree__',
|
|
'__flight_prefetch__',
|
|
] 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,
|
|
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
|
|
}
|