From c5639108361a47d9ec25dd10c4a3f548863f0024 Mon Sep 17 00:00:00 2001 From: Sebastian Borza Date: Tue, 24 Jul 2018 11:20:55 -0500 Subject: [PATCH] Adding in proper path processing (#488) --- router/path_hosted.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/router/path_hosted.go b/router/path_hosted.go index e3ab9f2..39da65c 100644 --- a/router/path_hosted.go +++ b/router/path_hosted.go @@ -3,13 +3,23 @@ package router import ( + "regexp" "strings" ) -// extractPath extracts path from hosted EG host name (.eventgateway([a-z-]*)?.io|slsgateway.com) +var hostedDomainPattern *regexp.Regexp + +func init() { + hostedDomainPattern = regexp.MustCompile("(eventgateway([a-z-]*)?.io|slsgateway.com)") +} + func extractPath(host, path string) string { - subdomain := strings.Split(host, ".")[0] - return basePath + subdomain + path + extracted := path + if hostedDomainPattern.Copy().MatchString(host) { + subdomain := strings.Split(host, ".")[0] + extracted = basePath + subdomain + path + } + return extracted } func systemPathFromSpace(space string) string {