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

include when checking Well-known, update server hint

This commit is contained in:
Connery Noble 2023-01-13 03:10:35 -08:00
parent 3ce83792f5
commit 075d603829
19 changed files with 26 additions and 36 deletions

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Nové album",
"login_form_button_text": "Přihlášení",
"login_form_email_hint": "tvůjmail@email.com",
"login_form_endpoint_hint": "http://ip-tvého-serveru:port/api",
"login_form_endpoint_hint": "http://ip-tvého-serveru:port/",
"login_form_endpoint_url": "URL adresa serveru",
"login_form_err_invalid_email": "Neplatný e-mail",
"login_form_err_leading_whitespace": "Úvodní mezera",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Nyt album",
"login_form_button_text": "Log ind",
"login_form_email_hint": "din-email@email.com",
"login_form_endpoint_hint": "http://din-server-ip:port/api",
"login_form_endpoint_hint": "http://din-server-ip:port/",
"login_form_endpoint_url": "Server Endpoint URL",
"login_form_err_invalid_email": "Ugyldig email",
"login_form_err_leading_whitespace": "Mellemrum før",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Neues Album",
"login_form_button_text": "Anmelden",
"login_form_email_hint": "deine@email.de",
"login_form_endpoint_hint": "http://deine-server-ip:port/api",
"login_form_endpoint_hint": "http://deine-server-ip:port/",
"login_form_endpoint_url": "Server URL",
"login_form_err_invalid_email": "Ungültige E-Mail",
"login_form_err_leading_whitespace": "Führendes Leerzichen",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "New album",
"login_form_button_text": "Login",
"login_form_email_hint": "youremail@email.com",
"login_form_endpoint_hint": "http://your-server-ip:port/api",
"login_form_endpoint_hint": "http://your-server-ip:port/",
"login_form_endpoint_url": "Server Endpoint URL",
"login_form_err_invalid_email": "Invalid Email",
"login_form_err_leading_whitespace": "Leading whitespace",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Nuevo álbum",
"login_form_button_text": "Iniciar Sesión",
"login_form_email_hint": "tucorreo@correo.com",
"login_form_endpoint_hint": "http://tu-ip-de-servidor:puerto/api",
"login_form_endpoint_hint": "http://tu-ip-de-servidor:puerto/",
"login_form_endpoint_url": "URL del servidor",
"login_form_err_invalid_email": "Correo electrónico no válido",
"login_form_err_leading_whitespace": "Espacio en blanco inicial",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Uusi albumi",
"login_form_button_text": "Kirjaudu",
"login_form_email_hint": "sahkopostisi@esimerkki.fi",
"login_form_endpoint_hint": "http://palvelimesi-osoite:portti/api",
"login_form_endpoint_hint": "http://palvelimesi-osoite:portti/",
"login_form_endpoint_url": "Palvelimen URL",
"login_form_err_invalid_email": "Virheellinen sähköpostiosoite",
"login_form_err_leading_whitespace": "Alussa välilyönti",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Nouvel album",
"login_form_button_text": "Connexion",
"login_form_email_hint": "votreemail@email.com",
"login_form_endpoint_hint": "http://adresse-ip-serveur:port/api",
"login_form_endpoint_hint": "http://adresse-ip-serveur:port/",
"login_form_endpoint_url": "URL du point d'accès au serveur",
"login_form_err_invalid_email": "Email invalide",
"login_form_err_leading_whitespace": "Espace en début de ligne",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Nuovo Album",
"login_form_button_text": "Login",
"login_form_email_hint": "tuaemail@email.com",
"login_form_endpoint_hint": "http://ip-del-tuo-server:port/api",
"login_form_endpoint_hint": "http://ip-del-tuo-server:port/",
"login_form_endpoint_url": "Server Endpoint URL",
"login_form_err_invalid_email": "Email non valida",
"login_form_err_leading_whitespace": "Whitespace all'inizio ",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "新しいアルバム",
"login_form_button_text": "ログイン",
"login_form_email_hint": "example@email.com",
"login_form_endpoint_hint": "https://example.com:port/api",
"login_form_endpoint_hint": "https://example.com:port/",
"login_form_endpoint_url": "サーバーエンドポイントURL",
"login_form_err_invalid_email": "メールアドレスが有効じゃないよ",
"login_form_err_leading_whitespace": "最初に半角スペースが含まれてるよ",

View file

@ -111,7 +111,7 @@
"library_page_new_album": "새 앨범",
"login_form_button_text": "로그인",
"login_form_email_hint": "youremail@email.com",
"login_form_endpoint_hint": "https://your-server-ip:port/api",
"login_form_endpoint_hint": "https://your-server-ip:port/",
"login_form_endpoint_url": "서버 엔드포인트 URL",
"login_form_err_invalid_email": "잘못된 이메일 형식입니다",
"login_form_err_leading_whitespace": "이메일 앞에 공백문자가 포함되어 있습니다",

View file

@ -77,7 +77,7 @@
"exif_bottom_sheet_location": "LOCATIE",
"login_form_button_text": "Login",
"login_form_email_hint": "jouwemail@email.com",
"login_form_endpoint_hint": "http://jouw-server-ip:port/api",
"login_form_endpoint_hint": "http://jouw-server-ip:port/",
"login_form_endpoint_url": "Server URL",
"login_form_err_invalid_email": "Ongeldige Email",
"login_form_err_leading_whitespace": "Spatie aan het begin",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Nowy album",
"login_form_button_text": "Login",
"login_form_email_hint": "twojmail@email.com",
"login_form_endpoint_hint": "http://ip-twojego-serwera:port/api",
"login_form_endpoint_hint": "http://ip-twojego-serwera:port/",
"login_form_endpoint_url": "URL Serwera",
"login_form_err_invalid_email": "Niepoprawny Email",
"login_form_err_leading_whitespace": "Białe znaki",

View file

@ -74,7 +74,7 @@
"exif_bottom_sheet_location": "LOCALIZAÇÃO",
"login_form_button_text": "Login",
"login_form_email_hint": "youremail@email.com",
"login_form_endpoint_hint": "http://your-server-ip:port/api",
"login_form_endpoint_hint": "http://your-server-ip:port/",
"login_form_endpoint_url": "Server Endpoint URL",
"login_form_err_invalid_email": "E-mail inválido",
"login_form_err_leading_whitespace": "Leading whitespace",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Novo Album",
"login_form_button_text": "Login",
"login_form_email_hint": "seuemail@email.com",
"login_form_endpoint_hint": "http://ip-do-seu-servidor:porta/api",
"login_form_endpoint_hint": "http://ip-do-seu-servidor:porta/",
"login_form_endpoint_url": "URL do endpoint do servidor",
"login_form_err_invalid_email": "Email Inválido",
"login_form_err_leading_whitespace": "Espaço em branco no início",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Новый альбом",
"login_form_button_text": "Login",
"login_form_email_hint": "youremail@email.com",
"login_form_endpoint_hint": "http://your-server-ip:port/api",
"login_form_endpoint_hint": "http://your-server-ip:port/",
"login_form_endpoint_url": "Server Endpoint URL",
"login_form_err_invalid_email": "Invalid Email",
"login_form_err_leading_whitespace": "Leading whitespace",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "Nový album",
"login_form_button_text": "Prihlásenie",
"login_form_email_hint": "tvojmail@email.com",
"login_form_endpoint_hint": "http://ip-tvojho-servera:port/api",
"login_form_endpoint_hint": "http://ip-tvojho-servera:port/",
"login_form_endpoint_url": "URL adresa servera",
"login_form_err_invalid_email": "Neplatný e-mail",
"login_form_err_leading_whitespace": "Úvodná medzera",

View file

@ -114,7 +114,7 @@
"library_page_new_album": "新建相册",
"login_form_button_text": "登录",
"login_form_email_hint": "youremail@email.com",
"login_form_endpoint_hint": "http://your-server-ip:port/api",
"login_form_endpoint_hint": "http://your-server-ip:port/",
"login_form_endpoint_url": "服务器地址",
"login_form_err_invalid_email": "请输入正确的邮箱",
"login_form_err_leading_whitespace": "前面空格",

View file

@ -35,12 +35,10 @@ class LoginForm extends HookConsumerWidget {
getServeLoginConfig() async {
if (!serverEndpointFocusNode.hasFocus) {
var urlText = serverEndpointController.text.trim();
var serverUrl = serverEndpointController.text.trim();
try {
var serverUrl = Uri.tryParse(urlText);
if (serverUrl != null) {
if (serverUrl.isNotEmpty) {
isLoading.value = true;
final serverEndpoint =
await apiService.resolveEndpoint(serverUrl.toString());

View file

@ -27,35 +27,27 @@ class ApiService {
}
/// Takes a server URL and attempts to resolve the API endpoint.
/// If no path is provided, a lookup for /.well-known/immich will
/// attempt to resolve the API endpoint. Otherwise, we assume the
/// input points to the API directly.
///
/// Input: [schema://]host[:port][/path]
/// schema - optional (default: https)
/// host - required
/// port - optional (default: based on schema)
/// path - optional (default: /)
/// path - optional
Future<String> resolveEndpoint(String serverUrl) async {
// Add schema if none is set
final urlWithSchema = serverUrl.startsWith(RegExp(r"https?://"))
? serverUrl
: "https://$serverUrl";
final url = Uri.parse(urlWithSchema);
final origin = url.origin;
// Remove trailing slash(es)
final url = urlWithSchema.replaceFirst(RegExp(r"/+$"), "");
// Trim trailing slash(es) from path
final path = url.path.replaceFirst(RegExp(r"/+$"), "");
if (path.isEmpty) {
// No path provided, lets check for /.well-known/immich
final wellKnownEndpoint = await getWellKnownEndpoint(origin);
if (wellKnownEndpoint.isNotEmpty) return wellKnownEndpoint;
}
// Check for /.well-known/immich
final wellKnownEndpoint = await getWellKnownEndpoint(url);
if (wellKnownEndpoint.isNotEmpty) return wellKnownEndpoint;
// Otherwise, assume the URL provided is the api endpoint
return "$origin$path";
return url;
}
Future<String> getWellKnownEndpoint(String baseUrl) async {