Skip to content

Commit

Permalink
comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DTCurrie committed Nov 19, 2024
1 parent 63f2e8a commit 5b5a564
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/backto.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ var hostnameWhitelist = map[string]bool{
"app.viam.com": true,
}

var prTempEnvPattern = "pr-(\\d+)-appmain-bplesliplq-uc.a.run.app"

// isWhitelisted returns true if the passed hostname is whitelisted or a temporary PR environment
func isWhitelisted(hostname string) bool {
isPRTempEnv, err := regexp.MatchString("pr-(\\d+)-appmain-bplesliplq-uc.a.run.app", hostname)
isPRTempEnv, err := regexp.MatchString(prTempEnvPattern, hostname)
if err != nil {
return false
}
Expand All @@ -25,6 +28,7 @@ func isWhitelisted(hostname string) bool {
return hostnameWhitelist[hostname]
}

// isAllowedURLScheme returns true if the passed URL is using a "https" schema, or "http" for "localhost" URLs
func isAllowedURLScheme(url *url.URL) bool {
if url.Scheme == "https" {
return true
Expand All @@ -43,6 +47,7 @@ func isAllowedURLScheme(url *url.URL) bool {
// - https://example.com -> false
// - http://app.viam.com/path/name -> false
// - https://app.viam.com/path/name -> true
// - http://localhost/path/name -> true
func IsValidBacktoURL(path string) bool {
normalized := strings.ReplaceAll(path, "\\", "/")
url, err := url.ParseRequestURI(normalized)
Expand Down

0 comments on commit 5b5a564

Please sign in to comment.