mirror of
https://github.com/immich-app/immich.git
synced 2025-01-04 02:46:47 +01:00
feat(.well-known): make schema optional (defaults to https)
This commit is contained in:
parent
6962df6340
commit
a51b06b453
19 changed files with 27 additions and 33 deletions
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "tvůjmail@email.com",
|
||||
"login_form_endpoint_hint": "http://ip-tvého-serveru:port/api",
|
||||
"login_form_endpoint_url": "URL adresa serveru",
|
||||
"login_form_err_http": "Prosím, uveďte http:// nebo https://",
|
||||
"login_form_err_invalid_email": "Neplatný e-mail",
|
||||
"login_form_err_leading_whitespace": "Úvodní mezera",
|
||||
"login_form_err_trailing_whitespace": "Koncová mezera",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "din-email@email.com",
|
||||
"login_form_endpoint_hint": "http://din-server-ip:port/api",
|
||||
"login_form_endpoint_url": "Server Endpoint URL",
|
||||
"login_form_err_http": "Angiv venligst http:// eller https://",
|
||||
"login_form_err_invalid_email": "Ugyldig email",
|
||||
"login_form_err_leading_whitespace": "Mellemrum før",
|
||||
"login_form_err_trailing_whitespace": "Mellemrum efter",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "deine@email.de",
|
||||
"login_form_endpoint_hint": "http://deine-server-ip:port/api",
|
||||
"login_form_endpoint_url": "Server URL",
|
||||
"login_form_err_http": "Bitte gebe http:// oder https:// an",
|
||||
"login_form_err_invalid_email": "Ungültige E-Mail",
|
||||
"login_form_err_leading_whitespace": "Führendes Leerzichen",
|
||||
"login_form_err_trailing_whitespace": "Folgendes Leerzeichen",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "youremail@email.com",
|
||||
"login_form_endpoint_hint": "http://your-server-ip:port/api",
|
||||
"login_form_endpoint_url": "Server Endpoint URL",
|
||||
"login_form_err_http": "Please specify http:// or https://",
|
||||
"login_form_err_invalid_email": "Invalid Email",
|
||||
"login_form_err_leading_whitespace": "Leading whitespace",
|
||||
"login_form_err_trailing_whitespace": "Trailing whitespace",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "tucorreo@correo.com",
|
||||
"login_form_endpoint_hint": "http://tu-ip-de-servidor:puerto/api",
|
||||
"login_form_endpoint_url": "URL del servidor",
|
||||
"login_form_err_http": "Por favor, especifique http:// o https://",
|
||||
"login_form_err_invalid_email": "Correo electrónico no válido",
|
||||
"login_form_err_leading_whitespace": "Espacio en blanco inicial",
|
||||
"login_form_err_trailing_whitespace": "Espacio en blanco al final",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "sahkopostisi@esimerkki.fi",
|
||||
"login_form_endpoint_hint": "http://palvelimesi-osoite:portti/api",
|
||||
"login_form_endpoint_url": "Palvelimen URL",
|
||||
"login_form_err_http": "Lisää http:// tai https://",
|
||||
"login_form_err_invalid_email": "Virheellinen sähköpostiosoite",
|
||||
"login_form_err_leading_whitespace": "Alussa välilyönti",
|
||||
"login_form_err_trailing_whitespace": "Lopussa välilyönti",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "votreemail@email.com",
|
||||
"login_form_endpoint_hint": "http://adresse-ip-serveur:port/api",
|
||||
"login_form_endpoint_url": "URL du point d'accès au serveur",
|
||||
"login_form_err_http": "Veuillez préciser http:// ou https://",
|
||||
"login_form_err_invalid_email": "Email invalide",
|
||||
"login_form_err_leading_whitespace": "Espace en début de ligne",
|
||||
"login_form_err_trailing_whitespace": "Espace de fin de ligne",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "tuaemail@email.com",
|
||||
"login_form_endpoint_hint": "http://ip-del-tuo-server:port/api",
|
||||
"login_form_endpoint_url": "Server Endpoint URL",
|
||||
"login_form_err_http": "Per favore specificare http:// o https://",
|
||||
"login_form_err_invalid_email": "Email non valida",
|
||||
"login_form_err_leading_whitespace": "Whitespace all'inizio ",
|
||||
"login_form_err_trailing_whitespace": "Whitespace alla fine",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "example@email.com",
|
||||
"login_form_endpoint_hint": "https://example.com:port/api",
|
||||
"login_form_endpoint_url": "サーバーエンドポイントURL",
|
||||
"login_form_err_http": "http://かhttps://かを指定してね",
|
||||
"login_form_err_invalid_email": "メールアドレスが有効じゃないよ",
|
||||
"login_form_err_leading_whitespace": "最初に半角スペースが含まれてるよ",
|
||||
"login_form_err_trailing_whitespace": "最後に半角スペースが含まれてるよ",
|
||||
|
|
|
@ -113,7 +113,6 @@
|
|||
"login_form_email_hint": "youremail@email.com",
|
||||
"login_form_endpoint_hint": "https://your-server-ip:port/api",
|
||||
"login_form_endpoint_url": "서버 엔드포인트 URL",
|
||||
"login_form_err_http": "엔드포인트는 http:// 또는 https://로 시작해야 합니다",
|
||||
"login_form_err_invalid_email": "잘못된 이메일 형식입니다",
|
||||
"login_form_err_leading_whitespace": "이메일 앞에 공백문자가 포함되어 있습니다",
|
||||
"login_form_err_trailing_whitespace": "이메일 뒤에 공백문자가 포함되어 있습니다",
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
"login_form_email_hint": "jouwemail@email.com",
|
||||
"login_form_endpoint_hint": "http://jouw-server-ip:port/api",
|
||||
"login_form_endpoint_url": "Server URL",
|
||||
"login_form_err_http": "Voer http:// of https:// in",
|
||||
"login_form_err_invalid_email": "Ongeldige Email",
|
||||
"login_form_err_leading_whitespace": "Spatie aan het begin",
|
||||
"login_form_err_trailing_whitespace": "Spatie aan het eind",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "twojmail@email.com",
|
||||
"login_form_endpoint_hint": "http://ip-twojego-serwera:port/api",
|
||||
"login_form_endpoint_url": "URL Serwera",
|
||||
"login_form_err_http": "Proszę określić http:// lub https://",
|
||||
"login_form_err_invalid_email": "Niepoprawny Email",
|
||||
"login_form_err_leading_whitespace": "Białe znaki",
|
||||
"login_form_err_trailing_whitespace": "Białe znaki po przecinku",
|
||||
|
|
|
@ -76,7 +76,6 @@
|
|||
"login_form_email_hint": "youremail@email.com",
|
||||
"login_form_endpoint_hint": "http://your-server-ip:port/api",
|
||||
"login_form_endpoint_url": "Server Endpoint URL",
|
||||
"login_form_err_http": "Please specify http:// or https://",
|
||||
"login_form_err_invalid_email": "E-mail inválido",
|
||||
"login_form_err_leading_whitespace": "Leading whitespace",
|
||||
"login_form_err_trailing_whitespace": "Trailing whitespace",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "seuemail@email.com",
|
||||
"login_form_endpoint_hint": "http://ip-do-seu-servidor:porta/api",
|
||||
"login_form_endpoint_url": "URL do endpoint do servidor",
|
||||
"login_form_err_http": "Por favor especifique http:// ou https://",
|
||||
"login_form_err_invalid_email": "Email Inválido",
|
||||
"login_form_err_leading_whitespace": "Espaço em branco no início",
|
||||
"login_form_err_trailing_whitespace": "Espaço em branco no fim",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "youremail@email.com",
|
||||
"login_form_endpoint_hint": "http://your-server-ip:port/api",
|
||||
"login_form_endpoint_url": "Server Endpoint URL",
|
||||
"login_form_err_http": "Please specify http:// or https://",
|
||||
"login_form_err_invalid_email": "Invalid Email",
|
||||
"login_form_err_leading_whitespace": "Leading whitespace",
|
||||
"login_form_err_trailing_whitespace": "Trailing whitespace",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "tvojmail@email.com",
|
||||
"login_form_endpoint_hint": "http://ip-tvojho-servera:port/api",
|
||||
"login_form_endpoint_url": "URL adresa servera",
|
||||
"login_form_err_http": "Prosím, uveďte http:// alebo https://",
|
||||
"login_form_err_invalid_email": "Neplatný e-mail",
|
||||
"login_form_err_leading_whitespace": "Úvodná medzera",
|
||||
"login_form_err_trailing_whitespace": "Koncové medzera",
|
||||
|
|
|
@ -116,7 +116,6 @@
|
|||
"login_form_email_hint": "youremail@email.com",
|
||||
"login_form_endpoint_hint": "http://your-server-ip:port/api",
|
||||
"login_form_endpoint_url": "服务器地址",
|
||||
"login_form_err_http": "请检查http://或https://",
|
||||
"login_form_err_invalid_email": "请输入正确的邮箱",
|
||||
"login_form_err_leading_whitespace": "前面空格",
|
||||
"login_form_err_trailing_whitespace": "后面空格",
|
||||
|
|
|
@ -217,11 +217,8 @@ class ServerEndpointInput extends StatelessWidget {
|
|||
}) : super(key: key);
|
||||
|
||||
String? _validateInput(String? url) {
|
||||
if (url?.startsWith(RegExp(r'https?://')) == true) {
|
||||
return null;
|
||||
} else {
|
||||
return 'login_form_err_http'.tr();
|
||||
}
|
||||
// Can we do any other validation here instead?
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -26,19 +26,33 @@ class ApiService {
|
|||
deviceInfoApi = DeviceInfoApi(_apiClient);
|
||||
}
|
||||
|
||||
/// Takes a server URL and attempts to resolve the API endpoint.
|
||||
///
|
||||
/// Input: [schema://]host[:port][/path]
|
||||
/// schema - optional (default: https)
|
||||
/// host - required
|
||||
/// port - optional (default: based on schema)
|
||||
/// path - optional (default: /.well-known/immich)
|
||||
resolveEndpoint(String serverUrl) async {
|
||||
// Sanitize URL to only include origin+path
|
||||
final url = Uri.parse(serverUrl);
|
||||
final baseUrl = "${url.origin}${url.path}";
|
||||
// Add schema if none is set
|
||||
final urlWithSchema = serverUrl.startsWith(RegExp(r"https?://"))
|
||||
? serverUrl
|
||||
: "https://$serverUrl";
|
||||
|
||||
// Remove trailing slash, if exists
|
||||
final endpoint = baseUrl[baseUrl.length - 1] == "/"
|
||||
? baseUrl.substring(0, baseUrl.length - 1)
|
||||
: baseUrl;
|
||||
final url = Uri.parse(urlWithSchema);
|
||||
final origin = url.origin;
|
||||
|
||||
// Check for .well-known definition, otherwise assume endpoint is full API address
|
||||
final apiEndpoint = await getWellKnownEndpoint(endpoint) ?? endpoint;
|
||||
return apiEndpoint;
|
||||
// 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) return wellKnownEndpoint;
|
||||
}
|
||||
|
||||
// Otherwise, assume the URL provided is the api endpoint
|
||||
return "$origin$path";
|
||||
}
|
||||
|
||||
getWellKnownEndpoint(String baseUrl) async {
|
||||
|
@ -61,7 +75,7 @@ class ApiService {
|
|||
return endpoint;
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint("Could not locate .well-known at $baseUrl: $e");
|
||||
debugPrint("Could not locate /.well-known/immich at $baseUrl");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue