2023-10-22 17:05:10 +02:00
|
|
|
import 'package:immich_mobile/shared/models/store.dart';
|
|
|
|
|
2023-01-19 17:45:37 +02:00
|
|
|
String sanitizeUrl(String url) {
|
|
|
|
// Add schema if none is set
|
|
|
|
final urlWithSchema =
|
|
|
|
url.startsWith(RegExp(r"https?://")) ? url : "https://$url";
|
|
|
|
|
|
|
|
// Remove trailing slash(es)
|
|
|
|
return urlWithSchema.replaceFirst(RegExp(r"/+$"), "");
|
|
|
|
}
|
2023-10-22 17:05:10 +02:00
|
|
|
|
|
|
|
String? getServerUrl() {
|
|
|
|
final serverUrl = Store.tryGet(StoreKey.serverEndpoint);
|
|
|
|
final serverUri = serverUrl != null ? Uri.tryParse(serverUrl) : null;
|
|
|
|
if (serverUri == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return serverUri.hasPort
|
|
|
|
? "${serverUri.scheme}://${serverUri.host}:${serverUri.port}"
|
|
|
|
: "${serverUri.scheme}://${serverUri.host}";
|
|
|
|
}
|