File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed
feature/presentation/page/setup_credential Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -101,4 +101,8 @@ class Helper {
101101 return ConstantErrorMessage ().failureUnknown;
102102 }
103103 }
104+
105+ String removeTrailingSlash (String input) {
106+ return input.replaceAll (RegExp (r'/+$' ), '' );
107+ }
104108}
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ class _SetupCredentialPageState extends State<SetupCredentialPage> {
148148 ) as bool ? ;
149149 }
150150 if (isContinue != null && isContinue) {
151- final hostname = controllerHostname.text.trim ();
151+ final hostname = helper. removeTrailingSlash ( controllerHostname.text. trim ()) .trim ();
152152 await sharedPreferencesManager.putString (SharedPreferencesManager .keyDomainApi, hostname);
153153 helper.setDomainApiToFlavor (hostname);
154154 di.init ();
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ dependencies:
9999
100100 # A cross platform plugin for displaying and scheduling local notifications for Flutter applications
101101 # with the ability to customize for each platform.
102- flutter_local_notifications : ^17.1.2
102+ flutter_local_notifications : 13.0.0
103103
104104 # The Font Awesome Icon pack available as Flutter Icons. Provides 1600 additional icons to use
105105 # in your apps.
Original file line number Diff line number Diff line change @@ -170,4 +170,25 @@ void main() {
170170 expect (unknownFailure, constantErrorMessage.failureUnknown);
171171 },
172172 );
173+
174+ test (
175+ 'pastikan function removeTrailingSlash bisa menghapus karakter "/" diakhir dari sebuah string.' ,
176+ () async {
177+ // arrange
178+ const input = 'https://example.com/' ;
179+ const input2 = 'https://example.com' ;
180+ const input3 = 'https://example.com////' ;
181+ const output = 'https://example.com' ;
182+
183+ // act
184+ final actual1 = helper.removeTrailingSlash (input);
185+ final actual2 = helper.removeTrailingSlash (input2);
186+ final actual3 = helper.removeTrailingSlash (input3);
187+
188+ // assert
189+ expect (actual1, output);
190+ expect (actual2, output);
191+ expect (actual3, output);
192+ },
193+ );
173194}
You can’t perform that action at this time.
0 commit comments