diff --git a/Program.cs b/Program.cs index 378d1fd..35449c1 100644 --- a/Program.cs +++ b/Program.cs @@ -34,8 +34,17 @@ if (app.Environment.IsDevelopment()) app.MapOpenApi(); } -app.UseHttpsRedirection(); -app.UseAuthorization(); +// HTTPS redirection is optional and disabled by default for Docker flexibility +// Users can enable it by setting ENABLE_HTTPS_REDIRECTION=true environment variable +// or EnableHttpsRedirection=true in appsettings.json +var enableHttpsRedirection = builder.Configuration.GetValue("EnableHttpsRedirection", false) || + Environment.GetEnvironmentVariable("ENABLE_HTTPS_REDIRECTION")?.Equals("true", StringComparison.OrdinalIgnoreCase) == true; +if (enableHttpsRedirection) +{ + app.UseHttpsRedirection(); +} + +// No authorization required - service is designed to run behind a reverse proxy if auth is needed app.MapControllers(); // Cleanup on shutdown diff --git a/Services/ScrapingService.cs b/Services/ScrapingService.cs index 6bdef20..3180ff0 100644 --- a/Services/ScrapingService.cs +++ b/Services/ScrapingService.cs @@ -124,8 +124,10 @@ public class ScrapingService : IScrapingService if (!string.IsNullOrEmpty(summaryText)) { // Parse "3 of 3 location results" or similar + // Pattern has 2 capture groups: (\d+) of (\d+) + // Groups[0] = full match, Groups[1] = first number, Groups[2] = second number (total) var countMatch = System.Text.RegularExpressions.Regex.Match(summaryText, @"(\d+)\s+of\s+(\d+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase); - if (countMatch.Success && countMatch.Groups.Count >= 3) + if (countMatch.Success && countMatch.Groups.Count >= 3 && countMatch.Groups[2].Success) { if (int.TryParse(countMatch.Groups[2].Value, out var total)) {