From fcd6e50aa80c02e536916bae4f854d12511985e4 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Fri, 6 Nov 2020 20:41:01 -0300 Subject: [PATCH] Add missing path-base option from .netconfig (#70) This option was not writtable in the model and was therefore not set when loading from configuration. --- src/dotnet-serve/CommandLineOptions.cs | 2 +- src/dotnet-serve/Program.cs | 1 + test/dotnet-serve.Tests/ConfigTests.cs | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dotnet-serve/CommandLineOptions.cs b/src/dotnet-serve/CommandLineOptions.cs index b4eadc1..ec96236 100644 --- a/src/dotnet-serve/CommandLineOptions.cs +++ b/src/dotnet-serve/CommandLineOptions.cs @@ -37,7 +37,7 @@ class CommandLineOptions public IPAddress[] Addresses { get; } [Option("--path-base ", Description = "The base URL path of postpended to the site url.")] - private string PathBase { get; } + public string PathBase { get; internal set; } [Option("--default-extensions:", CommandOptionType.SingleOrNoValue, Description = "A comma-delimited list of extensions to use when no extension is provided in the URL. [.html,.htm]")] public (bool HasValue, string Extensions) DefaultExtensions { get; } diff --git a/src/dotnet-serve/Program.cs b/src/dotnet-serve/Program.cs index 319dd5d..9060340 100644 --- a/src/dotnet-serve/Program.cs +++ b/src/dotnet-serve/Program.cs @@ -82,6 +82,7 @@ static void ReadConfig(ConfigSection config, CommandLineOptions model) model.UseGzip ??= config.GetBoolean("gzip"); model.UseBrotli ??= config.GetBoolean("brotli"); model.EnableCors ??= config.GetBoolean("cors"); + model.PathBase ??= config.GetString("path-base"); if (!model.UseTlsSpecified && config.TryGetBoolean("tls", out var tls)) { diff --git a/test/dotnet-serve.Tests/ConfigTests.cs b/test/dotnet-serve.Tests/ConfigTests.cs index ec04965..b3dc69e 100644 --- a/test/dotnet-serve.Tests/ConfigTests.cs +++ b/test/dotnet-serve.Tests/ConfigTests.cs @@ -40,6 +40,7 @@ public void ConfigurationProvidesDefaultOptions() mime = .fs=text/plain exclude-file = app.config exclude-file = appsettings.json + path-base = foo "); var program = new TestProgram(); @@ -60,6 +61,7 @@ public void ConfigurationProvidesDefaultOptions() Assert.Equal("password", options.CertificatePassword); Assert.True(options.UseGzip); Assert.True(options.EnableCors); + Assert.Equal("foo", options.PathBase); Assert.Contains("X-H1: value", options.Headers); Assert.Contains("X-H2: value", options.Headers);