mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Handle json! panick trying to serialize non utf8 lines
Instead of panicking when trying to handle non utf8 lines we should return `null` as line output. This way we can on the frontend detect if a file has any lines the api wasn't able to parse and fallback to show a file as a `Binary File`
This commit is contained in:
@@ -66,7 +66,7 @@ export type CommitBlob = z.infer<typeof commitBlobSchema>;
|
||||
type AdditionHunkLine = z.infer<typeof additionHunkLineSchema>;
|
||||
|
||||
const additionHunkLineSchema = object({
|
||||
line: string(),
|
||||
line: string().nullable(),
|
||||
lineNo: number(),
|
||||
type: literal("addition"),
|
||||
});
|
||||
@@ -74,7 +74,7 @@ const additionHunkLineSchema = object({
|
||||
type DeletionHunkLine = z.infer<typeof deletionHunkLineSchema>;
|
||||
|
||||
const deletionHunkLineSchema = object({
|
||||
line: string(),
|
||||
line: string().nullable(),
|
||||
lineNo: number(),
|
||||
type: literal("deletion"),
|
||||
});
|
||||
@@ -95,7 +95,7 @@ const diffFileSchema = object({
|
||||
type ContextHunkLine = z.infer<typeof contextHunkLineSchema>;
|
||||
|
||||
const contextHunkLineSchema = object({
|
||||
line: string(),
|
||||
line: string().nullable(),
|
||||
lineNoNew: number(),
|
||||
lineNoOld: number(),
|
||||
type: literal("context"),
|
||||
|
||||
Reference in New Issue
Block a user