add cleanup url util for removing stuff like `www.` from urls

This commit is contained in:
krawieck 2020-10-04 21:52:19 +02:00
parent 598200fa76
commit a8ac98284a
2 changed files with 12 additions and 1 deletions

10
lib/util/cleanup_url.dart Normal file
View File

@ -0,0 +1,10 @@
String cleanUpUrl(String url) {
if (url.startsWith('https://')) {
url = url.substring(8);
}
if (url.startsWith('www.')) {
url = url.substring(4);
}
return url;
}

View File

@ -13,6 +13,7 @@ import '../hooks/delayed_loading.dart';
import '../hooks/logged_in_action.dart';
import '../pages/full_post.dart';
import '../url_launcher.dart';
import '../util/cleanup_url.dart';
import '../util/extensions/api.dart';
import '../util/goto.dart';
import 'bottom_modal.dart';
@ -209,7 +210,7 @@ class Post extends HookWidget {
text: '@',
style: TextStyle(fontWeight: FontWeight.w300)),
TextSpan(
text: instanceUrl,
text: cleanUpUrl(instanceUrl),
style: TextStyle(fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()
..onTap =