@@ -161,10 +161,10 @@ private void ServerUrlInput_TextChanged(object sender, RoutedEventArgs e)
161161 }
162162 private UserProfile SetupUserProfile ( LoginUser user )
163163 {
164- string cleanedServerUrl = RemoveSpecialCharacters ( user . ServerUrl ) ;
164+ string cleanedServerUrl = WebHelper . RemoveSpecialCharactersFromUrl ( user . ServerUrl ) ;
165165 UserProfile profile = ProfileManager . CreateUserProfile ( cleanedServerUrl ) ;
166166 profile . ServerUrl = user . ServerUrl ;
167- Preferences . Set ( AppConfigKey . ServerUrl , user . ServerUrl , profile . UserConfigFile ) ;
167+ Preferences . Set ( AppConfigKey . ServerUrl , user . ServerUrl , profile . UserConfigFile , true ) ;
168168 if ( ! user . IsLoggedInWithSSO )
169169 {
170170 profile . Name = user . Username ;
@@ -404,27 +404,7 @@ private void ValidateSignUpData()
404404 }
405405 }
406406 }
407- private string RemoveSpecialCharacters ( string str )
408- {
409- if ( str . StartsWith ( "http://" , StringComparison . OrdinalIgnoreCase ) )
410- {
411- str = str . Substring ( 7 ) ;
412- }
413- else if ( str . StartsWith ( "https://" , StringComparison . OrdinalIgnoreCase ) )
414- {
415- str = str . Substring ( 8 ) ;
416- }
417-
418- StringBuilder sb = new StringBuilder ( ) ;
419- foreach ( char c in str )
420- {
421- if ( ( c >= '0' && c <= '9' ) || ( c >= 'A' && c <= 'Z' ) || ( c >= 'a' && c <= 'z' ) || c == '.' || c == '_' )
422- {
423- sb . Append ( c ) ;
424- }
425- }
426- return sb . ToString ( ) ;
427- }
407+
428408
429409 private void UserProfileContextMenu_Click ( object sender , RoutedEventArgs e )
430410 {
@@ -477,12 +457,12 @@ private void UserProfileEditSave_Click(object sender, RoutedEventArgs e)
477457 {
478458 ProfileManager . DeleteUserProfile ( profileToEdit ) ;
479459 ViewModel . UserProfiles . Remove ( profileToEdit ) ;
480- string cleanedServerUrl = RemoveSpecialCharacters ( ViewModel . EditUser . ServerUrl ) ;
460+ string cleanedServerUrl = WebHelper . RemoveSpecialCharactersFromUrl ( ViewModel . EditUser . ServerUrl ) ;
481461 UserProfile profile = ProfileManager . CreateUserProfile ( cleanedServerUrl ) ;
482462 profile . Name = ViewModel . EditUser . Username ;
483463 profile . ServerUrl = ViewModel . EditUser . ServerUrl ;
484464 ViewModel . UserProfiles . Add ( profile ) ;
485- Preferences . Set ( AppConfigKey . ServerUrl , ViewModel . EditUser . ServerUrl , profile . UserConfigFile ) ;
465+ Preferences . Set ( AppConfigKey . ServerUrl , ViewModel . EditUser . ServerUrl , profile . UserConfigFile , true ) ;
486466 Preferences . Set ( AppConfigKey . Username , ViewModel . EditUser . Username , profile . UserConfigFile ) ;
487467 Preferences . Set ( AppConfigKey . Password , ViewModel . EditUser . Password , profile . UserConfigFile , true ) ;
488468 }
@@ -507,13 +487,13 @@ private void CreateDemoUser()
507487 string demoUsername = "demo" ;
508488 string demoPassword = "demodemo" ;
509489
510- UserProfile demoProfile = ProfileManager . CreateUserProfile ( RemoveSpecialCharacters ( demoServerUrl ) ) ;
490+ UserProfile demoProfile = ProfileManager . CreateUserProfile ( WebHelper . RemoveSpecialCharactersFromUrl ( demoServerUrl ) ) ;
511491 demoProfile . Name = demoUsername ;
512492 demoProfile . ServerUrl = demoServerUrl ;
513493
514494 ViewModel . UserProfiles . Add ( demoProfile ) ;
515495
516- Preferences . Set ( AppConfigKey . ServerUrl , demoServerUrl , demoProfile . UserConfigFile ) ;
496+ Preferences . Set ( AppConfigKey . ServerUrl , demoServerUrl , demoProfile . UserConfigFile , true ) ;
517497 Preferences . Set ( AppConfigKey . Username , demoUsername , demoProfile . UserConfigFile ) ;
518498 Preferences . Set ( AppConfigKey . Password , demoPassword , demoProfile . UserConfigFile , true ) ;
519499 }
@@ -674,6 +654,6 @@ private async void UserRegistrationTextBox_KeyDown(object sender, System.Windows
674654 await SaveAndSignUp ( ) ;
675655 }
676656 }
677-
657+
678658 }
679659}
0 commit comments