Reputation:
Some users type https://google.com/
and some users type https://google.com
How to check If user type with slash or not? If user type with a slash How to remove slash?
Upvotes: 3
Views: 1924
Reputation: 1763
If you re doing lots of string manipulations you can use a sanitize package https://pub.dev/documentation/validators/latest/sanitizers/sanitizers-library.html, in your case it would be rtrim(str, ' /')
Upvotes: 2
Reputation:
var str = 'https://google.com/';
if (str.endsWith('/')) str = str.substring(0, str.length - 1);
Upvotes: 3