fix: uppercase extensions (#58)

This commit is contained in:
not-nullptr 2025-04-13 12:35:10 +01:00
parent 55ca64aa53
commit 53085ca9bc
2 changed files with 14 additions and 9 deletions

View File

@ -5,9 +5,10 @@ import { addToast } from "$lib/store/ToastProvider";
export class VertFile { export class VertFile {
public id: string = Math.random().toString(36).slice(2, 8); public id: string = Math.random().toString(36).slice(2, 8);
public readonly file: File;
public get from() { public get from() {
return "." + this.file.name.split(".").pop()!; return ("." + this.file.name.split(".").pop() || "").toLowerCase();
} }
public get name() { public get name() {
@ -41,11 +42,13 @@ export class VertFile {
return converter; return converter;
} }
constructor( constructor(file: File, to: string, blobUrl?: string) {
public readonly file: File, const ext = file.name.split(".").pop();
to: string, const newFile = new File(
blobUrl?: string, [file.slice(0, file.size, file.type)],
) { `${file.name.split(".").slice(0, -1).join(".")}.${ext?.toLowerCase()}`,
);
this.file = newFile;
this.to = to; this.to = to;
this.converters = converters.filter((c) => this.converters = converters.filter((c) =>
c.supportedFormats.includes(this.from), c.supportedFormats.includes(this.from),

View File

@ -76,7 +76,7 @@
<div class="flex gap-4 mt-8 md:flex-row flex-col"> <div class="flex gap-4 mt-8 md:flex-row flex-col">
{#each Object.entries(status) as [key, s]} {#each Object.entries(status) as [key, s]}
{@const Icon = s.icon} {@const Icon = s.icon}
<div class="file-category-card w-full"> <div class="file-category-card w-full flex flex-col">
<div class="file-category-card-inner"> <div class="file-category-card-inner">
<div <div
class={clsx("icon-container", { class={clsx("icon-container", {
@ -91,7 +91,7 @@
<span>{key}</span> <span>{key}</span>
</div> </div>
<div class="file-category-card-content"> <div class="file-category-card-content flex-grow">
{#if key === "Video"} {#if key === "Video"}
<p> <p>
Video uploads to a server for processing by Video uploads to a server for processing by
@ -102,7 +102,9 @@
>. >.
</p> </p>
{:else} {:else}
<p class="flex items-center justify-center gap-2"> <p
class="flex items-center justify-center gap-2 h-full"
>
<Check size="20" /> Fully supported <Check size="20" /> Fully supported
</p> </p>
{/if} {/if}