Skip to content

Commit

Permalink
change behaviour of hosted domain (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthenw committed Jan 16, 2018
1 parent 16e6c79 commit 34492df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,7 @@ func extractPath(host, path string) string {
rxp, _ := regexp.Compile(hostedDomain)
if rxp.MatchString(host) {
subdomain := strings.Split(host, ".")[0]
segments := strings.Split(subdomain, "---")
extracted = ""
for i := len(segments) - 1; i >= 0; i-- {
extracted += "/" + segments[i]
}
extracted += path
extracted = "/" + subdomain + path
}
return extracted
}
Expand Down
4 changes: 2 additions & 2 deletions router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ func TestRouterServeHTTP_ExtractPathFromHostedDomain(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
target := mock.NewMockTargeter(ctrl)
target.EXPECT().HTTPBackingFunction(http.MethodGet, "/name/app/dev/test").Return(nil, pathtree.Params{}, &cors.CORS{}).MaxTimes(1)
target.EXPECT().HTTPBackingFunction(http.MethodGet, "/custom/test").Return(nil, pathtree.Params{}, &cors.CORS{}).MaxTimes(1)
target.EXPECT().SubscribersOfEvent("/", event.SystemEventReceivedType).Return([]functions.FunctionID{}).MaxTimes(1)
router := testrouter(target)

req, _ := http.NewRequest(http.MethodGet, "https://dev---app---name.slsgateway.com/test", nil)
req, _ := http.NewRequest(http.MethodGet, "https://custom.slsgateway.com/test", nil)
recorder := httptest.NewRecorder()
router.ServeHTTP(recorder, req)

Expand Down

0 comments on commit 34492df

Please sign in to comment.