From 725f9103d6c24917209a1f092440efa348f8a3df Mon Sep 17 00:00:00 2001 From: ryg-git Date: Thu, 1 Apr 2021 00:46:23 +0530 Subject: [PATCH] implemented new comments --- lib/util/cleanup_url.dart | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/util/cleanup_url.dart b/lib/util/cleanup_url.dart index 0646973..6f3f610 100644 --- a/lib/util/cleanup_url.dart +++ b/lib/util/cleanup_url.dart @@ -1,19 +1,7 @@ -/// Strips protocol, 'www.', and trailing '/' from [url] aka. cleans it up -String cleanUpUrl(String url) { - var newUrl = url.toLowerCase(); - - if (newUrl.startsWith('https://')) { - newUrl = newUrl.substring(8); - } - if (newUrl.startsWith('www.')) { - newUrl = newUrl.substring(4); - } - if (newUrl.endsWith('/')) { - newUrl = newUrl.substring(0, newUrl.length - 1); - } - - return newUrl; -} +/// Returns host of a url without a leading 'www.' or protocol if present also +/// removes trailing '/' +String cleanUpUrl(String url) => + urlHost(url.startsWith('https://') ? url : 'https://$url'); // Returns host of a url without a leading 'www.' if present String urlHost(String url) {