Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
Change cleanUpUrl name
Browse files Browse the repository at this point in the history
  • Loading branch information
shilangyu committed Apr 6, 2021
1 parent fbb8ff3 commit 88e1f83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/pages/add_instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AddInstancePage extends HookWidget {
final debounce = useDebounce(() async {
if (prevInput == instanceController.text) return;

final inst = cleanUpUrl(instanceController.text);
final inst = normalizeInstanceHost(instanceController.text);
if (inst.isEmpty) {
isSite.value = null;
return;
Expand All @@ -47,7 +47,7 @@ class AddInstancePage extends HookWidget {
instanceController.removeListener(debounce);
};
}, []);
final inst = cleanUpUrl(instanceController.text);
final inst = normalizeInstanceHost(instanceController.text);
handleOnAdd() async {
try {
await accountsStore.addInstance(inst, assumeValid: true);
Expand Down
10 changes: 5 additions & 5 deletions lib/util/cleanup_url.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// Returns host of a url without a leading 'www.' or protocol if present also
/// removes trailing '/'
String cleanUpUrl(String url) {
/// Returns a normalized host of a (maybe) url without a leading www.
String normalizeInstanceHost(String maybeUrl) {
try {
return urlHost(url.startsWith('https://') ? url : 'https://$url');
} on FormatException catch (_) {
return urlHost(
maybeUrl.startsWith('https://') ? maybeUrl : 'https://$maybeUrl');
} on FormatException {
return '';
}
}
Expand Down

0 comments on commit 88e1f83

Please sign in to comment.