Skip to content

Commit

Permalink
chore: make regexp global
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Oct 3, 2024
1 parent 9fd5f16 commit 0e9c988
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/api/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e9c988

Please sign in to comment.