MCPcopy
hub / github.com/keploy/keploy / ReplacePort

Function ReplacePort

utils/utils.go:149–167  ·  view source on GitHub ↗
(currentURL string, port string)

Source from the content-addressed store, hash-verified

147}
148
149func ReplacePort(currentURL string, port string) (string, error) {
150 if port == "" {
151 return currentURL, fmt.Errorf("failed to replace port in case of docker env")
152 }
153
154 parsedURL, err := url.Parse(currentURL)
155
156 if err != nil {
157 return currentURL, err
158 }
159
160 if parsedURL.Port() == "" {
161 parsedURL.Host = parsedURL.Host + ":" + port
162 } else {
163 parsedURL.Host = strings.Replace(parsedURL.Host, parsedURL.Port(), port, 1)
164 }
165
166 return parsedURL.String(), nil
167}
168
169// GetReqMeta returns the metadata of the request
170func GetReqMeta(req *http.Request) map[string]string {

Callers 1

replacePortInTestCaseMethod · 0.92

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected