Skip to content

Commit f38532b

Browse files
authored
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.
1 parent 4467a1f commit f38532b

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

mkdocs-website/docs/en/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4343
- Fix failing Windows build due to unknown option by [thomas-senechal](https://github.com/thomas-senechal) in PR [#3208](https://github.com/wailsapp/wails/pull/3208)
4444
- Fix wrong baseURL when open window twice by @5aaee9 in PR [#3273](https://github.com/wailsapp/wails/pull/3273)
4545
- Fix ordering of if branches in `WebviewWindow.Restore` method by [@fbbdev](https://github.com/fbbdev) in [#3279](https://github.com/wailsapp/wails/pull/3279)
46+
- Correctly compute `startURL` across multiple `GetStartURL` invocations when `FRONTEND_DEVSERVER_URL` is present. [#3299](https://github.com/wailsapp/wails/pull/3299)
4647

4748
### Changed
4849

v3/internal/assetserver/assetserver.go

+10-17
Original file line numberDiff line numberDiff line change
@@ -148,26 +148,19 @@ func GetStartURL(userURL string) (string, error) {
148148
}
149149
port := parsedURL.Port()
150150
if port != "" {
151-
baseURL.Host = net.JoinHostPort(baseURL.Host, port)
151+
baseURL.Host = net.JoinHostPort(baseURL.Hostname(), port)
152152
startURL = baseURL.String()
153153
}
154-
} else {
155-
if userURL != "" {
156-
// parse the url
157-
parsedURL, err := url.Parse(userURL)
158-
if err != nil {
159-
return "", fmt.Errorf("Error parsing URL: " + err.Error())
160-
}
161-
if parsedURL.Scheme == "" {
162-
startURL = baseURL.ResolveReference(&url.URL{Path: userURL}).String()
163-
// if the original URL had a trailing slash, add it back
164-
if strings.HasSuffix(userURL, "/") && !strings.HasSuffix(startURL, "/") {
165-
startURL = startURL + "/"
166-
}
167-
} else {
168-
startURL = userURL
169-
}
154+
}
155+
156+
if userURL != "" {
157+
parsedURL, err := baseURL.Parse(userURL)
158+
if err != nil {
159+
return "", fmt.Errorf("Error parsing URL: " + err.Error())
170160
}
161+
162+
startURL = parsedURL.String()
171163
}
164+
172165
return startURL, nil
173166
}

0 commit comments

Comments
 (0)