summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-07-13 14:02:33 -0700
committerChristopher Brown <ccbrown112@gmail.com>2017-07-13 18:48:07 -0700
commita18479df0940be8503c9b88993490741793eba9e (patch)
treed839053025bc9705659fc89d96360792f8a16d72 /utils
parent764ff4cb64eb86c87a28a076eed28d8778f194d6 (diff)
downloadchat-a18479df0940be8503c9b88993490741793eba9e.tar.gz
chat-a18479df0940be8503c9b88993490741793eba9e.tar.bz2
chat-a18479df0940be8503c9b88993490741793eba9e.zip
Tweak WebSocket header-processing (#6929)
* fix * consolidate code
Diffstat (limited to 'utils')
-rw-r--r--utils/api.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/utils/api.go b/utils/api.go
index 663f53c16..d175e0c13 100644
--- a/utils/api.go
+++ b/utils/api.go
@@ -15,7 +15,15 @@ type OriginCheckerProc func(*http.Request) bool
func OriginChecker(r *http.Request) bool {
origin := r.Header.Get("Origin")
- return *Cfg.ServiceSettings.AllowCorsFrom == "*" || strings.Contains(*Cfg.ServiceSettings.AllowCorsFrom, origin)
+ if *Cfg.ServiceSettings.AllowCorsFrom == "*" {
+ return true
+ }
+ for _, allowed := range strings.Split(*Cfg.ServiceSettings.AllowCorsFrom, " ") {
+ if allowed == origin {
+ return true
+ }
+ }
+ return false
}
func GetOriginChecker(r *http.Request) OriginCheckerProc {