mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Trim trailing slashes from server URL.
This commit is contained in:
parent
b6f0df54a7
commit
50237c8167
@ -69,7 +69,7 @@ namespace Remotely.Desktop.Core.Services
|
||||
catch { }
|
||||
}
|
||||
Connection = new HubConnectionBuilder()
|
||||
.WithUrl($"{host}/CasterHub")
|
||||
.WithUrl($"{host.Trim().TrimEnd('/')}/CasterHub")
|
||||
.AddMessagePackProtocol()
|
||||
.WithAutomaticReconnect()
|
||||
.Build();
|
||||
|
||||
@ -214,24 +214,20 @@ namespace Remotely.Desktop.Linux.ViewModels
|
||||
}
|
||||
|
||||
await prompt.ShowDialog(MainWindow.Current);
|
||||
var result = prompt.ViewModel.Host?.Trim();
|
||||
var result = prompt.ViewModel.Host?.Trim()?.TrimEnd('/');
|
||||
|
||||
if (result is null)
|
||||
if (!Uri.TryCreate(result, UriKind.Absolute, out var serverUri) ||
|
||||
(serverUri.Scheme != Uri.UriSchemeHttp && serverUri.Scheme != Uri.UriSchemeHttps))
|
||||
{
|
||||
Logger.Write("Server URL is not valid.");
|
||||
await MessageBox.Show("Server URL must be a valid Uri (e.g. https://app.remotely.one).", "Invalid Server URL", MessageBoxType.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result.StartsWith("https://") && !result.StartsWith("http://"))
|
||||
{
|
||||
result = $"https://{result}";
|
||||
}
|
||||
if (result != Host)
|
||||
{
|
||||
Host = result;
|
||||
var config = _configService.GetConfig();
|
||||
config.Host = Host;
|
||||
_configService.Save(config);
|
||||
}
|
||||
Host = result;
|
||||
var config = _configService.GetConfig();
|
||||
config.Host = Host;
|
||||
_configService.Save(config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -257,18 +257,20 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
|
||||
prompt.Owner = App.Current?.MainWindow;
|
||||
prompt.ShowDialog();
|
||||
var result = prompt.ViewModel.Host?.Trim();
|
||||
if (!result.StartsWith("https://") && !result.StartsWith("http://"))
|
||||
var result = prompt.ViewModel.Host?.Trim()?.TrimEnd('/');
|
||||
|
||||
if (!Uri.TryCreate(result, UriKind.Absolute, out var serverUri) ||
|
||||
(serverUri.Scheme != Uri.UriSchemeHttp && serverUri.Scheme != Uri.UriSchemeHttps))
|
||||
{
|
||||
result = $"https://{result}";
|
||||
}
|
||||
if (result != Host)
|
||||
{
|
||||
Host = result;
|
||||
var config = _configService.GetConfig();
|
||||
config.Host = Host;
|
||||
_configService.Save(config);
|
||||
Logger.Write("Server URL is not valid.");
|
||||
MessageBox.Show("Server URL must be a valid Uri (e.g. https://app.remotely.one).", "Invalid Server URL", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
Host = result;
|
||||
var config = _configService.GetConfig();
|
||||
config.Host = Host;
|
||||
_configService.Save(config);
|
||||
}
|
||||
|
||||
public void ShutdownApp()
|
||||
|
||||
@ -12,7 +12,7 @@ namespace Remotely.Shared.Models
|
||||
|
||||
public string Host
|
||||
{
|
||||
get => _host;
|
||||
get => _host.TrimEnd('/');
|
||||
set
|
||||
{
|
||||
_host = value?.TrimEnd('/');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user