Change cleanUpUrl name
This commit is contained in:
parent
fbb8ff3a33
commit
88e1f8324f
|
@ -25,7 +25,7 @@ class AddInstancePage extends HookWidget {
|
||||||
final debounce = useDebounce(() async {
|
final debounce = useDebounce(() async {
|
||||||
if (prevInput == instanceController.text) return;
|
if (prevInput == instanceController.text) return;
|
||||||
|
|
||||||
final inst = cleanUpUrl(instanceController.text);
|
final inst = normalizeInstanceHost(instanceController.text);
|
||||||
if (inst.isEmpty) {
|
if (inst.isEmpty) {
|
||||||
isSite.value = null;
|
isSite.value = null;
|
||||||
return;
|
return;
|
||||||
|
@ -47,7 +47,7 @@ class AddInstancePage extends HookWidget {
|
||||||
instanceController.removeListener(debounce);
|
instanceController.removeListener(debounce);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
final inst = cleanUpUrl(instanceController.text);
|
final inst = normalizeInstanceHost(instanceController.text);
|
||||||
handleOnAdd() async {
|
handleOnAdd() async {
|
||||||
try {
|
try {
|
||||||
await accountsStore.addInstance(inst, assumeValid: true);
|
await accountsStore.addInstance(inst, assumeValid: true);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/// Returns host of a url without a leading 'www.' or protocol if present also
|
/// Returns a normalized host of a (maybe) url without a leading www.
|
||||||
/// removes trailing '/'
|
String normalizeInstanceHost(String maybeUrl) {
|
||||||
String cleanUpUrl(String url) {
|
|
||||||
try {
|
try {
|
||||||
return urlHost(url.startsWith('https://') ? url : 'https://$url');
|
return urlHost(
|
||||||
} on FormatException catch (_) {
|
maybeUrl.startsWith('https://') ? maybeUrl : 'https://$maybeUrl');
|
||||||
|
} on FormatException {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue