2022-09-15 16:53:51 +02:00
|
|
|
import type { NextParsedUrlQuery } from './request-meta'
|
|
|
|
|
|
|
|
const INTERNAL_QUERY_NAMES = [
|
|
|
|
'__nextFallback',
|
|
|
|
'__nextLocale',
|
|
|
|
'__nextDefaultLocale',
|
|
|
|
'__nextIsNotFound',
|
|
|
|
// RSC
|
2022-09-28 13:18:37 +02:00
|
|
|
'__rsc__',
|
2022-09-15 16:53:51 +02:00
|
|
|
// Routing
|
2022-09-28 13:18:37 +02:00
|
|
|
'__next_router_state_tree__',
|
|
|
|
'__next_router_prefetch__',
|
2022-09-15 16:53:51 +02:00
|
|
|
] 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
|
|
|
|
}
|