File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
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 @@ -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