HOTFIX: if file is not text, print not supported error text
This commit is contained in:
parent
c7008e2e99
commit
26fba986d7
2 changed files with 8 additions and 2 deletions
|
@ -24,7 +24,7 @@ function FileView() {
|
||||||
<a className="link" href={location.pathname.endsWith("/") ? location.pathname + ".." : location.pathname + "/.."}>
|
<a className="link" href={location.pathname.endsWith("/") ? location.pathname + ".." : location.pathname + "/.."}>
|
||||||
<DynamicIcon name="chevron-left" size={21} />
|
<DynamicIcon name="chevron-left" size={21} />
|
||||||
</a>
|
</a>
|
||||||
<b>{location.pathname}</b>
|
<b>{decodeURIComponent(location.pathname)}</b>
|
||||||
</div>
|
</div>
|
||||||
<div className="action-row">
|
<div className="action-row">
|
||||||
<a className="btn link" href={`/api/raw${location.pathname}`}>
|
<a className="btn link" href={`/api/raw${location.pathname}`}>
|
||||||
|
|
|
@ -16,7 +16,13 @@ export const useRaw = create<RawState>((set) => ({
|
||||||
return;
|
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();
|
const text = await res.text();
|
||||||
set({ data: text });
|
set({ data: text });
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in a new issue