fix: show a server's host instead of repeating its address
A connection saved without a name (including the one migrated from the single-server record) showed its URL as both title and subtitle. Fall back to the host, and migrate old records that stored the URL as the name.
This commit is contained in:
1 parent
13aca21d99
commit
265145af41
4 files changed
+28
-7
No files matched your search
@@ -7,6 +7,7 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"sort"
|
||||
|
||||
"github.com/egoist/asuka/sdk/secure"
|
||||
@@ -82,8 +83,12 @@ func migrateLegacy() []Connection {
|
||||
if old.ID == "" {
|
||||
old.ID = newID()
|
||||
}
|
||||
if old.Label == "" {
|
||||
old.Label = old.URL
|
||||
if old.Label == "" || old.Label == old.URL {
|
||||
if u, err := url.Parse(old.URL); err == nil && u.Host != "" {
|
||||
old.Label = u.Host
|
||||
} else {
|
||||
old.Label = old.URL
|
||||
}
|
||||
}
|
||||
// Clear it so the next launch does not migrate again.
|
||||
_ = store.Set(legacyKey, "")
|
||||
|
||||
Reference in new issue
Block a user