File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,21 @@ struct _AddAccountIndexView: View {
70
70
@State var loginTask : Task < Void , Never > ?
71
71
@State var path : NavigationPath = . init( )
72
72
let errorReport : ( ( Error ) -> Void ) ?
73
+ var instanceValidateError : String ? {
74
+ if instance. isEmpty {
75
+ return " "
76
+ }
77
+ if instance. contains ( " / " ) {
78
+ return L10n . Login. ValidationFailed. hostIncludingSlash
79
+ }
80
+ var components = URLComponents ( )
81
+ components. scheme = " https "
82
+ components. host = instance
83
+ if components. url == nil {
84
+ return L10n . Login. ValidationFailed. hostIncludingSlash
85
+ }
86
+ return nil
87
+ }
73
88
74
89
enum LoginState {
75
90
case fetchingServerInfo
@@ -106,7 +121,7 @@ struct _AddAccountIndexView: View {
106
121
} label: {
107
122
Text ( L10n . Login. loginButton)
108
123
}
109
- . disabled ( instance . count == 0 || loginState != nil )
124
+ . disabled ( instanceValidateError != nil || loginState != nil )
110
125
. accessibility ( identifier: " loginButton " )
111
126
#if DEBUG
112
127
Button {
@@ -120,6 +135,8 @@ struct _AddAccountIndexView: View {
120
135
} footer: {
121
136
if let loginState = loginState {
122
137
Text ( loginState. description)
138
+ } else if let instanceValidateError {
139
+ Text ( instanceValidateError)
123
140
}
124
141
}
125
142
}
Original file line number Diff line number Diff line change @@ -289,6 +289,10 @@ public enum L10n {
289
289
/// ログイン中
290
290
public static let title = L10n . tr ( " Login " , " progressDialog.title " )
291
291
}
292
+ public enum ValidationFailed {
293
+ /// ホスト名のみを入力してください (https:// や最後の / は含めないでください)
294
+ public static let hostIncludingSlash = L10n . tr ( " Login " , " validationFailed.hostIncludingSlash " )
295
+ }
292
296
public enum Welcome {
293
297
/// ようこそ、
294
298
/// %@
Original file line number Diff line number Diff line change 8
8
9
9
"title" = "ログイン";
10
10
"pleaseInputMastodonInstance" = "Mastodonのインスタンスを入力してください";
11
+ "validationFailed.hostIncludingSlash" = "ホスト名のみを入力してください (https:// や最後の / は含めないでください)";
11
12
"loginButton" = "ログイン";
12
13
13
14
"progressDialog.title" = "ログイン中";
You can’t perform that action at this time.
0 commit comments