Skip to content

Commit

Permalink
Rename originUrl to fetchUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
nabsul committed Apr 12, 2023
1 parent 1d30045 commit fcd7abd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions packages/next/src/server/lib/incremental-cache/fetch-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface NextFetchCacheParams {
internal?: boolean
fetchType?: string
fetchIdx?: number
originUrl?: string
fetchUrl?: string
}

export default class FetchCache implements CacheHandler {
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 7 additions & 7 deletions packages/next/src/server/lib/incremental-cache/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,7 +50,7 @@ export class CacheHandler {
_key: string,
_data: IncrementalCacheValue | null,
_fetchCache?: boolean,
_originUrl?: string,
_fetchUrl?: string,
_fetchIdx?: number
): Promise<void> {}
}
Expand Down Expand Up @@ -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
Expand All @@ -288,7 +288,7 @@ export class IncrementalCache {
const cacheData = await this.cacheHandler?.get(
pathname,
fetchCache,
originUrl,
fetchUrl,
fetchIdx
)

Expand Down Expand Up @@ -353,7 +353,7 @@ export class IncrementalCache {
entry.value,
curRevalidate,
fetchCache,
originUrl,
fetchUrl,
fetchIdx
)
}
Expand All @@ -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
Expand Down Expand Up @@ -398,7 +398,7 @@ export class IncrementalCache {
pathname,
data,
fetchCache,
originUrl,
fetchUrl,
fetchIdx
)
} catch (error) {
Expand Down
8 changes: 4 additions & 4 deletions packages/next/src/server/lib/patch-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ export function patchFetch({
}
}

const originUrl = url?.toString() ?? ''
const fetchUrl = url?.toString() ?? ''
const fetchIdx = staticGenerationStore.nextFetchId ?? 1
staticGenerationStore.nextFetchId = fetchIdx + 1

const doOriginalFetch = async () => {
// 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) => {
Expand Down Expand Up @@ -268,7 +268,7 @@ export function patchFetch({
},
revalidate,
true,
originUrl,
fetchUrl,
fetchIdx
)
} catch (err) {
Expand All @@ -291,7 +291,7 @@ export function patchFetch({
cacheKey,
true,
revalidate,
originUrl,
fetchUrl,
fetchIdx
)

Expand Down

0 comments on commit fcd7abd

Please sign in to comment.