Redirect links in search

This commit is contained in:
video-prize-ranch 2023-08-10 02:39:15 +00:00 committed by video-prize-ranch
parent 5892445df7
commit 7467792ae9
2 changed files with 9 additions and 0 deletions

View File

@ -13,6 +13,10 @@ func HandleSearch(c *fiber.Ctx) error {
query := c.Query("q")
if utils.ImgurRe.MatchString(query) {
return c.Redirect(utils.ImgurRe.ReplaceAllString(query, ""))
}
/*page := "1"
if c.Query("page") != "" {
page = c.Query("page")

5
utils/regex.go Normal file
View File

@ -0,0 +1,5 @@
package utils
import "regexp"
var ImgurRe = regexp.MustCompile(`https?://(i\.)?imgur\.com`)