fix: guard undefined contents in diff renderer to fix share viewer SSR crash (#21763)

This commit is contained in:
YGoetschel
2026-05-07 18:55:40 +08:00
committed by GitHub
parent 30c4fcb1a5
commit fea9a0bd4c
2 changed files with 8 additions and 4 deletions
+6 -2
View File
@@ -128,8 +128,12 @@ function DiffSSRViewer<T>(props: SSRDiffFileProps<T>) {
prerenderedHTML: local.preloadedDiff.prerenderedHTML,
}
: {
oldFile: local.before,
newFile: local.after,
oldFile: local.before
? { ...local.before, contents: typeof local.before.contents === "string" ? local.before.contents : "" }
: local.before,
newFile: local.after
? { ...local.after, contents: typeof local.after.contents === "string" ? local.after.contents : "" }
: local.after,
lineAnnotations: annotations,
fileContainer: fileDiffRef,
containerWrapper: container,