Buckets:
| // TypeScript trick to simulate opaque types, like in Flow. | |
| type Opaque<K, T> = T & { __brand: K } | |
| // Only functions in this module should be allowed to create CacheKeys. | |
| export type NormalizedPathname = Opaque<'NormalizedPathname', string> | |
| export type NormalizedSearch = Opaque<'NormalizedSearch', string> | |
| export type NormalizedNextUrl = Opaque<'NormalizedNextUrl', string> | |
| export type RouteCacheKey = Opaque< | |
| 'RouteCacheKey', | |
| { | |
| pathname: NormalizedPathname | |
| search: NormalizedSearch | |
| nextUrl: NormalizedNextUrl | null | |
| // TODO: Eventually the dynamic params will be added here, too. | |
| } | |
| > | |
| export function createCacheKey( | |
| originalHref: string, | |
| nextUrl: string | null | |
| ): RouteCacheKey { | |
| const originalUrl = new URL(originalHref) | |
| const cacheKey = { | |
| pathname: originalUrl.pathname as NormalizedPathname, | |
| search: originalUrl.search as NormalizedSearch, | |
| nextUrl: nextUrl as NormalizedNextUrl | null, | |
| } as RouteCacheKey | |
| return cacheKey | |
| } | |
Xet Storage Details
- Size:
- 978 Bytes
- Xet hash:
- ff2df11ac210ebbc5b2c4e3d1e4294eceb8de7882a84c4bd1e901a91f527b046
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.