Unverified Commit bf894257 authored by Nabeel Sulieman's avatar Nabeel Sulieman Committed by GitHub

Rename originUrl to fetchUrl (#48315)

### What?

Rename originUrl to fetchUrl for clarity.
Also remove remove it from origin fetch annotation because the data is
redundant.

### Why?

- The word fetch better matches the other two parameters fetchType and
fetchIdx
- Because the fetch/origin URL is the actual URL being performed on the
origin fetch, it will always be duplicate data
parent 6be8c590
......@@ -9,7 +9,7 @@ interface NextFetchCacheParams {
internal?: boolean
fetchType?: string
fetchIdx?: number
originUrl?: string
fetchUrl?: string
}
export default class FetchCache implements CacheHandler {
......@@ -76,7 +76,7 @@ export default class FetchCache implements CacheHandler {
public async get(
key: string,
fetchCache?: boolean,
originUrl?: string,
fetchUrl?: string,
fetchIdx?: number
) {
if (!fetchCache) return null
......@@ -96,7 +96,7 @@ export default class FetchCache implements CacheHandler {
const fetchParams: NextFetchCacheParams = {
internal: true,
fetchType: 'fetch-get',
originUrl,
fetchUrl: fetchUrl,
fetchIdx,
}
const res = await fetch(
......@@ -168,7 +168,7 @@ export default class FetchCache implements CacheHandler {
key: string,
data: CacheHandlerValue['value'],
fetchCache?: boolean,
originUrl?: string,
fetchUrl?: string,
fetchIdx?: number
) {
if (!fetchCache) return
......@@ -196,7 +196,7 @@ export default class FetchCache implements CacheHandler {
const fetchParams: NextFetchCacheParams = {
internal: true,
fetchType: 'fetch-set',
originUrl,
fetchUrl,
fetchIdx,
}
const res = await fetch(
......
......@@ -40,7 +40,7 @@ export class CacheHandler {
public async get(
_key: string,
_fetchCache?: boolean,
_originUrl?: string,
_fetchUrl?: string,
_fetchIdx?: number
): Promise<CacheHandlerValue | null> {
return {} as any
......@@ -50,7 +50,7 @@ export class CacheHandler {
_key: string,
_data: IncrementalCacheValue | null,
_fetchCache?: boolean,
_originUrl?: string,
_fetchUrl?: string,
_fetchIdx?: number
): Promise<void> {}
}
......@@ -271,7 +271,7 @@ export class IncrementalCache {
pathname: string,
fetchCache?: boolean,
revalidate?: number,
originUrl?: string,
fetchUrl?: string,
fetchIdx?: number
): Promise<IncrementalCacheEntry | null> {
// we don't leverage the prerender cache in dev mode
......@@ -288,7 +288,7 @@ export class IncrementalCache {
const cacheData = await this.cacheHandler?.get(
pathname,
fetchCache,
originUrl,
fetchUrl,
fetchIdx
)
......@@ -353,7 +353,7 @@ export class IncrementalCache {
entry.value,
curRevalidate,
fetchCache,
originUrl,
fetchUrl,
fetchIdx
)
}
......@@ -366,7 +366,7 @@ export class IncrementalCache {
data: IncrementalCacheValue | null,
revalidateSeconds?: number | false,
fetchCache?: boolean,
originUrl?: string,
fetchUrl?: string,
fetchIdx?: number
) {
if (this.dev && !fetchCache) return
......@@ -398,7 +398,7 @@ export class IncrementalCache {
pathname,
data,
fetchCache,
originUrl,
fetchUrl,
fetchIdx
)
} catch (error) {
......
......@@ -223,7 +223,7 @@ export function patchFetch({
}
}
const originUrl = url?.toString() ?? ''
const fetchUrl = url?.toString() ?? ''
const fetchIdx = staticGenerationStore.nextFetchId ?? 1
staticGenerationStore.nextFetchId = fetchIdx + 1
......@@ -231,7 +231,7 @@ export function patchFetch({
// add metadata to init without editing the original
const clonedInit = {
...init,
next: { ...init?.next, fetchType: 'origin', fetchIdx, originUrl },
next: { ...init?.next, fetchType: 'origin', fetchIdx },
}
return originFetch(input, clonedInit).then(async (res) => {
......@@ -258,7 +258,7 @@ export function patchFetch({
},
revalidate,
true,
originUrl,
fetchUrl,
fetchIdx
)
} catch (err) {
......@@ -281,7 +281,7 @@ export function patchFetch({
cacheKey,
true,
revalidate,
originUrl,
fetchUrl,
fetchIdx
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment