Fix regex detection.
This commit is contained in:
parent
2c1342a20e
commit
8c1ab0b53b
1 changed files with 9 additions and 1 deletions
10
main.go
10
main.go
|
@ -185,8 +185,16 @@ func Upload(c echo.Context) error {
|
||||||
|
|
||||||
UserAgent := c.Request().UserAgent()
|
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.String(http.StatusOK, fileUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Redirect(http.StatusMovedPermanently, "/files/"+file.Filename)
|
return c.Redirect(http.StatusMovedPermanently, "/files/"+file.Filename)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue