From 8c1ab0b53b9f7eee895ed789b4c9713f4c3fb3c3 Mon Sep 17 00:00:00 2001 From: CronyAkatsuki Date: Thu, 21 Dec 2023 12:23:11 +0100 Subject: [PATCH] Fix regex detection. --- main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index c525ab3..eef5e0e 100644 --- a/main.go +++ b/main.go @@ -185,8 +185,16 @@ func Upload(c echo.Context) error { UserAgent := c.Request().UserAgent() - if regexp.MatchString("^curl/.*", UserAgent); err != nil { + log.Print(UserAgent) + + match, err := regexp.MatchString("^curl/.*", UserAgent) + if err != nil { + log.Fatal(err) + } + + if match { return c.String(http.StatusOK, fileUrl) } + return c.Redirect(http.StatusMovedPermanently, "/files/"+file.Filename) }