Correctly compute 'startURL' when using a frontend development server. (#3299)

* Fix computing 'startURL' when 'FRONTEND_DEVSERVER_URL' is present.

* Respect provided URL when computing 'startURL' and 'FRONTEND_DEVSERVER_URL' is present.

* Update changelog.

* Correctly produce absolute URI in 'GetStartURL' when input is provided.
This commit is contained in:
Josh Drake
2024-03-08 18:06:14 +11:00
committed by GitHub
parent 4467a1ffa2
commit f38532bcf5
2 changed files with 12 additions and 18 deletions
+11 -18
View File
@@ -148,26 +148,19 @@ func GetStartURL(userURL string) (string, error) {
}
port := parsedURL.Port()
if port != "" {
baseURL.Host = net.JoinHostPort(baseURL.Host, port)
baseURL.Host = net.JoinHostPort(baseURL.Hostname(), port)
startURL = baseURL.String()
}
} else {
if userURL != "" {
// parse the url
parsedURL, err := url.Parse(userURL)
if err != nil {
return "", fmt.Errorf("Error parsing URL: " + err.Error())
}
if parsedURL.Scheme == "" {
startURL = baseURL.ResolveReference(&url.URL{Path: userURL}).String()
// if the original URL had a trailing slash, add it back
if strings.HasSuffix(userURL, "/") && !strings.HasSuffix(startURL, "/") {
startURL = startURL + "/"
}
} else {
startURL = userURL
}
}
}
if userURL != "" {
parsedURL, err := baseURL.Parse(userURL)
if err != nil {
return "", fmt.Errorf("Error parsing URL: " + err.Error())
}
startURL = parsedURL.String()
}
return startURL, nil
}