From 74b699cc3cc96b2b0361613e44793bbfc90ef256 Mon Sep 17 00:00:00 2001 From: Alula Date: Mon, 24 Nov 2025 01:58:07 +0100 Subject: [PATCH] Add support for .ovl file extension and refactor it slightly --- src/components/FileDropZone.tsx | 14 ++++++-------- src/constants.ts | 4 ++++ src/pages/PatcherPage.tsx | 12 ++++++++++-- 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 src/constants.ts diff --git a/src/components/FileDropZone.tsx b/src/components/FileDropZone.tsx index 563d676..d2b2302 100644 --- a/src/components/FileDropZone.tsx +++ b/src/components/FileDropZone.tsx @@ -1,5 +1,6 @@ import { FileDown } from "lucide-react"; import { useRef, useState } from "react"; +import { SUPPORTED_EXTENSIONS } from "../constants"; interface FileDropZoneProps { onFileSelected: (file: File) => void; @@ -32,11 +33,7 @@ export function FileDropZone({ onFileSelected }: FileDropZoneProps) { setIsDragging(false); const files = Array.from(e.dataTransfer.files); - const nroFile = files.find((file) => file.name.endsWith(".nro")); - - if (nroFile) { - onFileSelected(nroFile); - } else if (files.length > 0) { + if (files.length > 0) { onFileSelected(files[0]); } }; @@ -81,7 +78,6 @@ export function FileDropZone({ onFileSelected }: FileDropZoneProps) { @@ -90,9 +86,11 @@ export function FileDropZone({ onFileSelected }: FileDropZoneProps) {

- {isDragging ? "Drop file now" : "Select NRO File"} + {isDragging ? "Drop file now" : "Select File"}

-

Drag & drop or click to browse

+

+ Drag & drop or click to browse ({SUPPORTED_EXTENSIONS.join(", ")}) +

); diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..af633cb --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,4 @@ +export const SUPPORTED_EXTENSIONS = [".nro", ".ovl"] as const; + +export type SupportedExtension = (typeof SUPPORTED_EXTENSIONS)[number]; + diff --git a/src/pages/PatcherPage.tsx b/src/pages/PatcherPage.tsx index 10c417c..c7b20a1 100644 --- a/src/pages/PatcherPage.tsx +++ b/src/pages/PatcherPage.tsx @@ -64,8 +64,16 @@ export function PatcherPage({ appendSuffix }: PatcherPageProps) { let downloadName = currentFile.name; if (appendSuffix) { - downloadName = downloadName.replace(/\.nro$/i, "_patched.nro"); - if (downloadName === currentFile.name) downloadName += "_patched.nro"; + const extensionMatch = downloadName.match(/\.(nro|ovl)$/i); + if (extensionMatch) { + const ext = extensionMatch[1].toLowerCase(); + downloadName = downloadName.replace( + new RegExp(`\\.${ext}$`, "i"), + `_patched.${ext}`, + ); + } else { + downloadName += "_patched"; + } } a.download = downloadName;