@@ -192,7 +192,7 @@ var (
192192)
193193
194194func (router * Router ) eventFromRequest (r * http.Request ) (* eventpkg.Event , string , error ) {
195- path := extractPath (r )
195+ path := extractPath (r . Host , r . URL . Path )
196196 eventType := extractEventType (r )
197197
198198 mime := r .Header .Get ("content-type" )
@@ -247,7 +247,9 @@ func (router *Router) handleHTTPEvent(event *eventpkg.Event, w http.ResponseWrit
247247 reqMethod = r .Header .Get ("Access-Control-Request-Method" )
248248 }
249249
250- backingFunction , params , corsConfig := router .targetCache .HTTPBackingFunction (strings .ToUpper (reqMethod ), r .URL .EscapedPath ())
250+ backingFunction , params , corsConfig := router .targetCache .HTTPBackingFunction (
251+ strings .ToUpper (reqMethod ), extractPath (r .Host , r .URL .EscapedPath ()),
252+ )
251253 if backingFunction == nil {
252254 router .log .Debug ("Function not found for HTTP event." , zap .Object ("event" , event ))
253255 http .Error (w , "resource not found" , http .StatusNotFound )
@@ -481,13 +483,13 @@ func (router *Router) isDraining() bool {
481483 return false
482484}
483485
484- func extractPath (r * http. Request ) string {
485- path := r . URL . Path
486+ func extractPath (host , path string ) string {
487+ extracted := path
486488 rxp , _ := regexp .Compile (hostedDomain )
487- if rxp .MatchString (r . Host ) {
488- path = "/" + strings .Split (r . Host , "." )[0 ] + path
489+ if rxp .MatchString (host ) {
490+ extracted = "/" + strings .Split (host , "." )[0 ] + extracted
489491 }
490- return path
492+ return extracted
491493}
492494
493495func extractEventType (r * http.Request ) eventpkg.Type {
0 commit comments