mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +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:
@@ -39,6 +39,9 @@
|
||||
let highlighting: { new?: string[]; old?: string[] } | undefined = undefined;
|
||||
let syntaxHighlightingLoading: boolean = false;
|
||||
let preview = false;
|
||||
const binaryLines =
|
||||
fileDiff.type === "plain" &&
|
||||
fileDiff.hunks.some(h => h.lines.some(l => !l.line));
|
||||
$: extension = filePath.split(".").pop();
|
||||
|
||||
onMount(() => {
|
||||
@@ -449,7 +452,7 @@
|
||||
</svelte:fragment>
|
||||
|
||||
<div class="container">
|
||||
{#if fileDiff.type === "plain"}
|
||||
{#if fileDiff.type === "plain" && !binaryLines}
|
||||
{#if fileDiff.hunks.length > 0 && !preview}
|
||||
<table class="diff" data-file-diff-select>
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user