summaryrefslogtreecommitdiffstats
path: root/utils/api.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-07-13 14:02:33 -0700
committerChristopher Speller <crspeller@gmail.com>2017-07-13 14:02:33 -0700
commit5c3c909c8541f26ae09577338d2302bed2a2f3a9 (patch)
treea6939d5db3dd8e2da3b2b4c971ef5d504832043f /utils/api.go
parenta1f17c1f8482f3c38e17cabe2365c76a1a2f32d4 (diff)
downloadchat-5c3c909c8541f26ae09577338d2302bed2a2f3a9.tar.gz
chat-5c3c909c8541f26ae09577338d2302bed2a2f3a9.tar.bz2
chat-5c3c909c8541f26ae09577338d2302bed2a2f3a9.zip
Tweak WebSocket header-processing (#6929)
* fix * consolidate code
Diffstat (limited to 'utils/api.go')
-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 {