rsnext/packages/next/server/internal-utils.ts
Tim Neutkens b79d72d4b3
Rename flight parameters to rsc/next (#40979)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-09-28 13:18:37 +02:00

38 lines
812 B
TypeScript

import type { NextParsedUrlQuery } from './request-meta'
const INTERNAL_QUERY_NAMES = [
'__nextFallback',
'__nextLocale',
'__nextDefaultLocale',
'__nextIsNotFound',
// RSC
'__rsc__',
// Routing
'__next_router_state_tree__',
'__next_router_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
}