Skip to content

Commit 848b2db

Browse files
committed
fixes
1 parent d4d0f57 commit 848b2db

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

gateway/mw_version_check.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package gateway
22

33
import (
44
"errors"
5+
"github.com/getkin/kin-openapi/routers"
56
"net/http"
7+
"net/url"
68
"time"
79

8-
"github.com/getkin/kin-openapi/routers"
9-
1010
"github.com/TykTechnologies/tyk/apidef"
1111
"github.com/TykTechnologies/tyk/apidef/oas"
1212
"github.com/TykTechnologies/tyk/internal/middleware"
@@ -90,8 +90,14 @@ func (v *VersionCheck) ProcessRequest(w http.ResponseWriter, r *http.Request, _
9090
}
9191

9292
if v.Spec.IsOAS {
93-
new_listen_path := v.Spec.Proxy.ListenPath[:len(v.Spec.Proxy.ListenPath)-1] + "-" + targetVersion
94-
r.URL.Path = new_listen_path + v.Spec.StripListenPath(r.URL.Path)
93+
target_api := v.Gw.apisByID[subVersionID]
94+
stripped_path := v.Spec.StripListenPath(r.URL.Path)
95+
new_path, err := url.JoinPath(target_api.Proxy.ListenPath, stripped_path)
96+
if err != nil {
97+
log.Errorf("Url Join Error, err: %s", err)
98+
return errors.New(http.StatusText(http.StatusInternalServerError)), http.StatusInternalServerError
99+
}
100+
r.URL.Path = new_path
95101
} else {
96102
v.Spec.SanitizeProxyPaths(r)
97103
}

0 commit comments

Comments
 (0)