@@ -46,10 +46,8 @@ struct SessionEditor: View {
46
46
@State private var token : String = " "
47
47
@State private var badURL = false
48
48
@State private var insecureURL = false
49
- @State private var insecureAlertShown = false
50
49
51
- @State private var urlValid : Bool = false
52
-
50
+
53
51
var body : some View {
54
52
NavigationStack {
55
53
Form {
@@ -65,25 +63,28 @@ struct SessionEditor: View {
65
63
let temp = URL ( string: $0)
66
64
if temp? . scheme != nil && temp? . scheme != " " {
67
65
url = temp
68
- if ( url? . absoluteString . starts ( with : /[a-zA-Z]+:$/ ) ) ! && ! ( url ? . absoluteString . starts ( with : /https:$/ ) ) ! && !insecureAlertShown {
66
+ if ( url? . scheme ? . lowercased ( ) ) == ( " http " ) {
69
67
insecureURL = true
68
+ } else {
69
+ insecureURL = false
70
70
}
71
71
}
72
72
}
73
73
) )
74
74
. disableAutocorrection ( true )
75
75
. textInputAutocapitalization ( . never)
76
- . alert ( isPresented: $insecureURL) {
77
- Alert ( title: Text ( " Insecure URL " ) , message: Text ( " We strongly recommend using HTTPS for security reasons. Press OK to continue. " ) )
78
- }
79
- . onChange ( of: insecureURL) {
80
- if insecureURL{
81
- insecureAlertShown = true
82
- }
83
- }
84
76
} label: {
85
77
Text ( " URL: " )
86
78
}
79
+ if insecureURL {
80
+ let warningMessage = " ⚠️ We strongly recommend using HTTPS. "
81
+ TextField ( " " , text: Binding (
82
+ get: { warningMessage } ,
83
+ set: { _ in } // Prevents user from modifying the text
84
+ ) )
85
+ . disabled ( true ) // Prevents user input
86
+ . foregroundColor ( . red)
87
+ }
87
88
}
88
89
. toolbar {
89
90
ToolbarItem ( placement: . principal) {
0 commit comments