5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 23:23:48 +08:00

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 01:06:14 -06:00 committed by GitHub
parent 4467a1ffa2
commit f38532bcf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 18 deletions

View File

@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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) - 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)
- Fix wrong baseURL when open window twice by @5aaee9 in PR [#3273](https://github.com/wailsapp/wails/pull/3273) - Fix wrong baseURL when open window twice by @5aaee9 in PR [#3273](https://github.com/wailsapp/wails/pull/3273)
- Fix ordering of if branches in `WebviewWindow.Restore` method by [@fbbdev](https://github.com/fbbdev) in [#3279](https://github.com/wailsapp/wails/pull/3279) - Fix ordering of if branches in `WebviewWindow.Restore` method by [@fbbdev](https://github.com/fbbdev) in [#3279](https://github.com/wailsapp/wails/pull/3279)
- Correctly compute `startURL` across multiple `GetStartURL` invocations when `FRONTEND_DEVSERVER_URL` is present. [#3299](https://github.com/wailsapp/wails/pull/3299)
### Changed ### Changed

View File

@ -148,26 +148,19 @@ func GetStartURL(userURL string) (string, error) {
} }
port := parsedURL.Port() port := parsedURL.Port()
if port != "" { if port != "" {
baseURL.Host = net.JoinHostPort(baseURL.Host, port) baseURL.Host = net.JoinHostPort(baseURL.Hostname(), port)
startURL = baseURL.String() 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 return startURL, nil
} }