From 0e9c9882c919c79585493c82c2b8d282aaa75c32 Mon Sep 17 00:00:00 2001 From: Kang Ming Date: Thu, 3 Oct 2024 01:47:43 -0700 Subject: [PATCH] chore: make regexp global --- internal/api/middleware.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/api/middleware.go b/internal/api/middleware.go index 0f83e9235..e2598b180 100644 --- a/internal/api/middleware.go +++ b/internal/api/middleware.go @@ -173,12 +173,12 @@ func isIgnoreCaptchaRoute(req *http.Request) bool { var emailLabelPattern = regexp.MustCompile("[+][^@]+@") +// we don't need to enforce the check on these endpoints since they don't send emails +var containsNonEmailSendingPath = regexp.MustCompile(`^/(admin|token|verify)`) + func (a *API) isValidAuthorizedEmail(w http.ResponseWriter, req *http.Request) (context.Context, error) { ctx := req.Context() - // we don't need to enforce the check on these endpoints since they don't send emails - containsNonEmailSendingPath := regexp.MustCompile(`^/(admin|token|verify)`) - // skip checking for authorized email addresses if it's an admin request if containsNonEmailSendingPath.MatchString(req.URL.Path) || req.Method == http.MethodGet || req.Method == http.MethodDelete { return ctx, nil