commit df20c13a35523e8e80d466f034f1f411d908fbe0 parent 8f36474abf8841e11c4acbe56487c3dbb0f10658 Author: breadcat <breadcat@users.noreply.github.com> Date: Wed, 25 Feb 2026 00:00:31 +0000 Append existing file extension when renaming file if missing Diffstat:
| M | static/rename-file.js | | | 10 | +++++++++- |
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/static/rename-file.js b/static/rename-file.js @@ -4,12 +4,20 @@ document.addEventListener("DOMContentLoaded", () => { const fileID = button.dataset.fileId; const currentName = button.dataset.currentName; - const newName = prompt("Enter new filename (include extension):", currentName); + let newName = prompt("Enter new filename:", currentName); if (!newName) { return; } + const lastDot = currentName.lastIndexOf('.'); + const currentExt = lastDot !== -1 ? currentName.slice(lastDot) : ''; + + // If newName has no extension and the original did, append it + if (currentExt && !newName.includes('.')) { + newName = newName + currentExt; + } + const form = document.getElementById(`renameForm-${fileID}`); form.querySelector('input[name="newfilename"]').value = newName; form.submit();