1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-19 18:26:46 +01:00

fix casting issue with resovled url

This commit is contained in:
Connery Noble 2023-01-12 15:35:54 -08:00
parent 99892ddb35
commit 3ce83792f5
2 changed files with 6 additions and 6 deletions

View file

@ -25,7 +25,7 @@ class LoginForm extends HookConsumerWidget {
final passwordController =
useTextEditingController.fromValue(TextEditingValue.empty);
final serverEndpointController =
useTextEditingController(text: 'login_form_endpoint_hint'.tr());
useTextEditingController.fromValue(TextEditingValue.empty);
final apiService = ref.watch(apiServiceProvider);
final serverEndpointFocusNode = useFocusNode();
final isSaveLoginInfo = useState<bool>(false);

View file

@ -36,7 +36,7 @@ class ApiService {
/// host - required
/// port - optional (default: based on schema)
/// path - optional (default: /)
resolveEndpoint(String serverUrl) async {
Future<String> resolveEndpoint(String serverUrl) async {
// Add schema if none is set
final urlWithSchema = serverUrl.startsWith(RegExp(r"https?://"))
? serverUrl
@ -51,14 +51,14 @@ class ApiService {
if (path.isEmpty) {
// No path provided, lets check for /.well-known/immich
final wellKnownEndpoint = await getWellKnownEndpoint(origin);
if (wellKnownEndpoint) return wellKnownEndpoint;
if (wellKnownEndpoint.isNotEmpty) return wellKnownEndpoint;
}
// Otherwise, assume the URL provided is the api endpoint
return "$origin$path";
}
getWellKnownEndpoint(String baseUrl) async {
Future<String> getWellKnownEndpoint(String baseUrl) async {
final Client client = Client();
try {
@ -69,7 +69,7 @@ class ApiService {
if (res.statusCode == 200) {
final data = jsonDecode(res.body);
final endpoint = data['api']['endpoint'] as String;
final endpoint = data['api']['endpoint'].toString();
if (endpoint.startsWith('/')) {
// Full URL is relative to base
@ -81,7 +81,7 @@ class ApiService {
debugPrint("Could not locate /.well-known/immich at $baseUrl");
}
return null;
return "";
}
setAccessToken(String accessToken) {