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);