mirror of
https://github.com/coalaura/whiskr.git
synced 2025-09-08 17:06:42 +00:00
cleanup file select
This commit is contained in:
@@ -1549,7 +1549,7 @@
|
|||||||
$upload.addEventListener("click", async () => {
|
$upload.addEventListener("click", async () => {
|
||||||
const files = await selectFile(
|
const files = await selectFile(
|
||||||
// the ultimate list
|
// the ultimate list
|
||||||
".adoc,.bash,.bashrc,.bat,.c,.cc,.cfg,.cjs,.cmd,.conf,.cpp,.cs,.css,.csv,.cxx,.dockerfile,.dockerignore,.editorconfig,.env,.fish,.fs,.fsx,.gitattributes,.gitignore,.go,.gradle,.groovy,.h,.hh,.hpp,.htm,.html,.ini,.ipynb,.java,.jl,.js,.json,.jsonc,.jsx,.kt,.kts,.less,.log,.lua,.m,.makefile,.markdown,.md,.mjs,.mk,.mm,.php,.phtml,.pl,.pm,.profile,.properties,.ps1,.psql,.py,.pyw,.r,.rb,.rs,.rst,.sass,.scala,.scss,.sh,.sql,.svelte,.swift,.t,.toml,.ts,.tsv,.tsx,.txt,.vb,.vue,.xhtml,.xml,.xsd,.xsl,.xslt,.yaml,.yml,.zig,.zsh",
|
"text/*",
|
||||||
true,
|
true,
|
||||||
file => {
|
file => {
|
||||||
if (!file.name) {
|
if (!file.name) {
|
||||||
@@ -1558,10 +1558,10 @@
|
|||||||
throw new Error("File name too long (max 512 characters)");
|
throw new Error("File name too long (max 512 characters)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof file.content !== "string") {
|
if (!file.content) {
|
||||||
throw new Error("File is not a text file");
|
|
||||||
} else if (!file.content) {
|
|
||||||
throw new Error("File is empty");
|
throw new Error("File is empty");
|
||||||
|
} else if (file.content.includes("\0")) {
|
||||||
|
throw new Error("File is not a text file");
|
||||||
} else if (file.content.length > 4 * 1024 * 1024) {
|
} else if (file.content.length > 4 * 1024 * 1024) {
|
||||||
throw new Error("File is too big (max 4MB)");
|
throw new Error("File is too big (max 4MB)");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user