Skip to content

Commit 68b8907

Browse files
committedFeb 21, 2025
fix(core): avoid recursive function patching
1 parent 04ce992 commit 68b8907

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎packages/unhead/src/composables.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export function useHeadSafe<T extends Unhead<any>>(unhead: T, input: HeadSafe =
2020
export function useSeoMeta<T extends Unhead<any>>(unhead: T, input: UseSeoMetaInput = {}, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput> {
2121
unhead.use(FlatMetaPlugin)
2222
function normalize(input: UseSeoMetaInput) {
23+
// @ts-expect-error untyped
24+
if (input._flatMeta) {
25+
return input
26+
}
2327
const { title, titleTemplate, ...meta } = input || {}
2428
return {
2529
title,
@@ -28,8 +32,14 @@ export function useSeoMeta<T extends Unhead<any>>(unhead: T, input: UseSeoMetaIn
2832
}
2933
}
3034
const entry = unhead.push(normalize(input), options)
35+
// just in case
3136
const corePatch = entry.patch
32-
entry.patch = input => corePatch(normalize(input))
37+
// @ts-expect-error runtime
38+
if (!entry.__patched) {
39+
entry.patch = input => corePatch(normalize(input))
40+
// @ts-expect-error runtime
41+
entry.__patched = true
42+
}
3343
return entry
3444
}
3545

0 commit comments

Comments
 (0)
Please sign in to comment.