fix casting issue with resovled url
This commit is contained in:
@@ -25,7 +25,7 @@ class LoginForm extends HookConsumerWidget {
|
|||||||
final passwordController =
|
final passwordController =
|
||||||
useTextEditingController.fromValue(TextEditingValue.empty);
|
useTextEditingController.fromValue(TextEditingValue.empty);
|
||||||
final serverEndpointController =
|
final serverEndpointController =
|
||||||
useTextEditingController(text: 'login_form_endpoint_hint'.tr());
|
useTextEditingController.fromValue(TextEditingValue.empty);
|
||||||
final apiService = ref.watch(apiServiceProvider);
|
final apiService = ref.watch(apiServiceProvider);
|
||||||
final serverEndpointFocusNode = useFocusNode();
|
final serverEndpointFocusNode = useFocusNode();
|
||||||
final isSaveLoginInfo = useState<bool>(false);
|
final isSaveLoginInfo = useState<bool>(false);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class ApiService {
|
|||||||
/// host - required
|
/// host - required
|
||||||
/// port - optional (default: based on schema)
|
/// port - optional (default: based on schema)
|
||||||
/// path - optional (default: /)
|
/// path - optional (default: /)
|
||||||
resolveEndpoint(String serverUrl) async {
|
Future<String> resolveEndpoint(String serverUrl) async {
|
||||||
// Add schema if none is set
|
// Add schema if none is set
|
||||||
final urlWithSchema = serverUrl.startsWith(RegExp(r"https?://"))
|
final urlWithSchema = serverUrl.startsWith(RegExp(r"https?://"))
|
||||||
? serverUrl
|
? serverUrl
|
||||||
@@ -51,14 +51,14 @@ class ApiService {
|
|||||||
if (path.isEmpty) {
|
if (path.isEmpty) {
|
||||||
// No path provided, lets check for /.well-known/immich
|
// No path provided, lets check for /.well-known/immich
|
||||||
final wellKnownEndpoint = await getWellKnownEndpoint(origin);
|
final wellKnownEndpoint = await getWellKnownEndpoint(origin);
|
||||||
if (wellKnownEndpoint) return wellKnownEndpoint;
|
if (wellKnownEndpoint.isNotEmpty) return wellKnownEndpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, assume the URL provided is the api endpoint
|
// Otherwise, assume the URL provided is the api endpoint
|
||||||
return "$origin$path";
|
return "$origin$path";
|
||||||
}
|
}
|
||||||
|
|
||||||
getWellKnownEndpoint(String baseUrl) async {
|
Future<String> getWellKnownEndpoint(String baseUrl) async {
|
||||||
final Client client = Client();
|
final Client client = Client();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -69,7 +69,7 @@ class ApiService {
|
|||||||
|
|
||||||
if (res.statusCode == 200) {
|
if (res.statusCode == 200) {
|
||||||
final data = jsonDecode(res.body);
|
final data = jsonDecode(res.body);
|
||||||
final endpoint = data['api']['endpoint'] as String;
|
final endpoint = data['api']['endpoint'].toString();
|
||||||
|
|
||||||
if (endpoint.startsWith('/')) {
|
if (endpoint.startsWith('/')) {
|
||||||
// Full URL is relative to base
|
// Full URL is relative to base
|
||||||
@@ -81,7 +81,7 @@ class ApiService {
|
|||||||
debugPrint("Could not locate /.well-known/immich at $baseUrl");
|
debugPrint("Could not locate /.well-known/immich at $baseUrl");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
setAccessToken(String accessToken) {
|
setAccessToken(String accessToken) {
|
||||||
|
|||||||
Reference in New Issue
Block a user