diff options
author | Chris <ccbrown112@gmail.com> | 2017-07-13 14:02:33 -0700 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-07-13 14:02:33 -0700 |
commit | 5c3c909c8541f26ae09577338d2302bed2a2f3a9 (patch) | |
tree | a6939d5db3dd8e2da3b2b4c971ef5d504832043f /utils | |
parent | a1f17c1f8482f3c38e17cabe2365c76a1a2f32d4 (diff) | |
download | chat-5c3c909c8541f26ae09577338d2302bed2a2f3a9.tar.gz chat-5c3c909c8541f26ae09577338d2302bed2a2f3a9.tar.bz2 chat-5c3c909c8541f26ae09577338d2302bed2a2f3a9.zip |
Tweak WebSocket header-processing (#6929)
* fix
* consolidate code
Diffstat (limited to 'utils')
-rw-r--r-- | utils/api.go | 10 |
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 { |