File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ export default function endpoint() {
20
20
$ ( '#new_endpoint' ) . click ( addEndpoint ) ;
21
21
$ ( '#reset' ) . click ( resetEndpoint ) ;
22
22
23
+ $ ( '#server_url' ) . keyup ( validateURL ) ;
24
+
23
25
init ( ) ;
24
26
} ) ;
25
27
return true ;
@@ -64,10 +66,21 @@ function addEndpoint(e) {
64
66
setStorage ( 'config.server_url' , serverUrl ) ;
65
67
setStorage ( 'config.app_id' , appId ) ;
66
68
69
+ const UrlReg = / ^ (?: h t t p ( s ) ? : \/ \/ ) ? [ \w . - ] + (?: \. [ \w \. - ] + ) + [ \w \- \. _ ~ : / ? # [ \] @ ! \$ & ' \( \) \* \+ , ; = . ] + $ / ;
70
+
71
+ if ( ! UrlReg . test ( serverUrl ) ) {
72
+ $ ( '#error' )
73
+ . html ( 'Please enter a valid server URL' )
74
+ . show ( ) ;
75
+ return ;
76
+ }
77
+
67
78
checkConnection ( appId , serverUrl ) ;
68
79
}
69
80
70
81
function resetEndpoint ( ) {
71
82
setStorage ( 'config.app_id' , getDefaultEndpoint ( ) . appId ) ;
72
83
setStorage ( 'config.server_url' , getDefaultEndpoint ( ) . url ) ;
73
84
}
85
+
86
+ const validateURL = e => { } ;
You can’t perform that action at this time.
0 commit comments