diff --git a/interfacer/src/browsh/raw_text_server.go b/interfacer/src/browsh/raw_text_server.go index 75ccd12..bc144aa 100644 --- a/interfacer/src/browsh/raw_text_server.go +++ b/interfacer/src/browsh/raw_text_server.go @@ -8,6 +8,7 @@ import ( "crypto/rand" "io" "time" + "regexp" "github.com/ulule/limiter" "github.com/ulule/limiter/drivers/store/memory" @@ -83,7 +84,7 @@ func handleHTTPServerRequest(w http.ResponseWriter, r *http.Request) { return } w.Header().Set("Cache-Control", "public, max-age=600") - if (strings.Contains(urlForBrowsh, "mail.google.com")) { + if (isDisallowedURL(urlForBrowsh)) { http.Redirect(w, r, "/", 301) return } @@ -111,6 +112,11 @@ func handleHTTPServerRequest(w http.ResponseWriter, r *http.Request) { waitForResponse(rawTextRequestID, w) } +func isDisallowedURL(urlForBrowsh string) bool { + r, _ := regexp.Compile("[mail|accounts].google.com") + return r.MatchString(urlForBrowsh) +} + func isProductionHTTP(r *http.Request) bool { if (strings.Contains(r.Host, "brow.sh")) { return r.Header.Get("X-Forwarded-Proto") == "http"