Skip to content

Commit

Permalink
Add missing path-base option from .netconfig (#70)
Browse files Browse the repository at this point in the history
This option was not writtable in the model and was therefore
not set when loading from configuration.
  • Loading branch information
kzu authored Nov 6, 2020
1 parent d630dd6 commit fcd6e50
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dotnet-serve/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CommandLineOptions
public IPAddress[] Addresses { get; }

[Option("--path-base <PATH>", Description = "The base URL path of postpended to the site url.")]
private string PathBase { get; }
public string PathBase { get; internal set; }

[Option("--default-extensions:<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; }
Expand Down
1 change: 1 addition & 0 deletions src/dotnet-serve/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
2 changes: 2 additions & 0 deletions test/dotnet-serve.Tests/ConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit fcd6e50

Please sign in to comment.