UI.cs - Listen to "localhost" by default

This commit is contained in:
CmTheLuke 2020-01-29 11:43:42 -05:00 committed by GitHub
parent ce22521c7b
commit 5bc4d48971
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -33,7 +33,7 @@ namespace Ooui
static string host = "*"; static string host = "*";
public static string Host { public static string Host {
get => host; get => host == "*" ? "localhost" : host;
set { set {
if (!string.IsNullOrWhiteSpace (value) && host != value) { if (!string.IsNullOrWhiteSpace (value) && host != value) {
host = value; host = value;
@ -191,9 +191,8 @@ namespace Ooui
} }
public static string GetUrl (string path) public static string GetUrl (string path)
{ {
var localhost = host == "*" ? "localhost" : host; var url = $"http://{Host}:{port}{path}";
var url = $"http://{localhost}:{port}{path}";
return url; return url;
} }
@ -205,7 +204,7 @@ namespace Ooui
if (serverCts != null) return; if (serverCts != null) return;
serverCts = new CancellationTokenSource (); serverCts = new CancellationTokenSource ();
var token = serverCts.Token; var token = serverCts.Token;
var listenerPrefix = $"http://{host}:{port}/"; var listenerPrefix = $"http://{Host}:{port}/";
Task.Run (() => RunAsync (listenerPrefix, token), token); Task.Run (() => RunAsync (listenerPrefix, token), token);
} }