Skip to content

Commit 6c8405b

Browse files
committed
Exclude Purpose: prefetch header from comparing visit params
1 parent d38d186 commit 6c8405b

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

packages/core/src/prefetched.ts

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cloneDeep } from 'es-toolkit'
12
import { objectsAreEqual } from './objectUtils'
23
import { Response } from './response'
34
import { timeToMs } from './time'
@@ -205,23 +206,35 @@ class PrefetchedRequests {
205206
)
206207
}
207208

209+
protected withoutPurposePrefetchHeader(params: ActiveVisit): ActiveVisit {
210+
const newParams = cloneDeep(params)
211+
if (newParams.headers['Purpose'] === 'prefetch') {
212+
delete newParams.headers['Purpose']
213+
}
214+
return newParams
215+
}
216+
208217
protected paramsAreEqual(params1: ActiveVisit, params2: ActiveVisit): boolean {
209-
return objectsAreEqual<ActiveVisit>(params1, params2, [
210-
'showProgress',
211-
'replace',
212-
'prefetch',
213-
'onBefore',
214-
'onStart',
215-
'onProgress',
216-
'onFinish',
217-
'onCancel',
218-
'onSuccess',
219-
'onError',
220-
'onPrefetched',
221-
'onCancelToken',
222-
'onPrefetching',
223-
'async',
224-
])
218+
return objectsAreEqual<ActiveVisit>(
219+
this.withoutPurposePrefetchHeader(params1),
220+
this.withoutPurposePrefetchHeader(params2),
221+
[
222+
'showProgress',
223+
'replace',
224+
'prefetch',
225+
'onBefore',
226+
'onStart',
227+
'onProgress',
228+
'onFinish',
229+
'onCancel',
230+
'onSuccess',
231+
'onError',
232+
'onPrefetched',
233+
'onCancelToken',
234+
'onPrefetching',
235+
'async',
236+
],
237+
)
225238
}
226239
}
227240

0 commit comments

Comments
 (0)