diff --git a/pages/search.go b/pages/search.go index 6b8a2ec..4a2164e 100644 --- a/pages/search.go +++ b/pages/search.go @@ -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") diff --git a/utils/regex.go b/utils/regex.go new file mode 100644 index 0000000..839dd88 --- /dev/null +++ b/utils/regex.go @@ -0,0 +1,5 @@ +package utils + +import "regexp" + +var ImgurRe = regexp.MustCompile(`https?://(i\.)?imgur\.com`) \ No newline at end of file