From 26fba986d75a47c63f660aaaf9de60cf47a77361 Mon Sep 17 00:00:00 2001 From: Project_IO Date: Tue, 18 Mar 2025 00:18:34 +0900 Subject: [PATCH] HOTFIX: if file is not text, print not supported error text --- src/components/file-view/index.tsx | 2 +- src/store/raw.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/file-view/index.tsx b/src/components/file-view/index.tsx index 7db6d73..ea23e72 100644 --- a/src/components/file-view/index.tsx +++ b/src/components/file-view/index.tsx @@ -24,7 +24,7 @@ function FileView() { - {location.pathname} + {decodeURIComponent(location.pathname)}
diff --git a/src/store/raw.ts b/src/store/raw.ts index 1260fb6..c32cb9c 100644 --- a/src/store/raw.ts +++ b/src/store/raw.ts @@ -16,7 +16,13 @@ export const useRaw = create((set) => ({ return; } + const contentType = res.headers.get("Content-Type"); + if (!contentType || !contentType.includes("text")) { + set({ data: "this file is not supported showing preview" }); + return; + } + const text = await res.text(); - set({ data: text }); + set({ data: text }); } }));