mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
17 lines
387 B
Go
17 lines
387 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"regexp"
|
|
)
|
|
|
|
func checkRedirectGood2(req *http.Request, via []*http.Request) error {
|
|
// GOOD: the host of `req.URL` must be `example.com`, `www.example.com` or `beta.example.com`
|
|
re := `^((www|beta)\.)?example\.com/`
|
|
if matched, _ := regexp.MatchString(re, req.URL.Host); matched {
|
|
return nil
|
|
}
|
|
return errors.New("Invalid redirect")
|
|
}
|