taggart

Simple golang tagging filesystem webapp
Log | Files | Refs

commit ef249d39a052c409b8fddcff83c23d57ece6ccf1
parent f63e6add2dd53befa137ffe9fe4af52713484204
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Mon, 22 Sep 2025 16:32:31 +0100

Add file extension if missing from custom name

Diffstat:
Mmain.go | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/main.go b/main.go @@ -198,8 +198,14 @@ func uploadFromURLHandler(w http.ResponseWriter, r *http.Request) { // Determine filename var filename string + urlExt := filepath.Ext(parsedURL.Path) // get original extension from URL + if customFilename != "" { filename = customFilename + // If custom filename has no extension, append URL's extension + if filepath.Ext(filename) == "" && urlExt != "" { + filename += urlExt + } } else { // Use basename from URL as before parts := strings.Split(parsedURL.Path, "/")