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 }); } }));