Nager.PublicSuffix
                                
                                
                                
                                    Nager.PublicSuffix copied to clipboard
                            
                            
                            
                        Replacement for WebTldRuleProvider
After upgrading the package to v3, WebTldRuleProvider is no longer recognized. It seems there is no equivalent provider we can use as a replacement. CachedHttpRuleProvider requires a number of arguments. Can you re-add this provider with default suitable arguments?
SimpleHttpRuleProvider?
There is no caching with this RuleProvider :/.
can you briefly explain to me where you use the library, console application, website...?
This is with a console application, the goal is to extract the root domain from a URI, just like in the first example shown in the v2 Readme:
var domainParser = new DomainParser(new WebTldRuleProvider());
var domainInfo = domainParser.Parse("sub.test.co.uk");
//domainInfo.Domain = "test";
//domainInfo.Hostname = "sub.test.co.uk";
//domainInfo.RegistrableDomain = "test.co.uk";
//domainInfo.SubDomain = "sub";
//domainInfo.TLD = "co.uk";
                                    
                                    
                                    
                                
Required NuGet Packages
- Microsoft.Extensions.Logging
 - Microsoft.Extensions.Logging.Console
 
using var loggerFactory = LoggerFactory.Create(builder =>
{
    builder.AddConsole();
});
var ruleProviderLogger = loggerFactory.CreateLogger<CachedHttpRuleProvider>();
IConfiguration configuration = new ConfigurationBuilder()
    .AddInMemoryCollection(new List<KeyValuePair<string, string?>>
    {
        new("Nager:PublicSuffix:DataUrl", "https://publicsuffix.org/list/public_suffix_list.dat")
    })
    .Build();
var httpClient = new HttpClient();
var cacheProvider = new Nager.PublicSuffix.RuleProviders.CacheProviders.LocalFileSystemCacheProvider();
var ruleProvider = new CachedHttpRuleProvider(ruleProviderLogger, configuration, cacheProvider, httpClient);
await ruleProvider.BuildAsync();
var domainParser = new DomainParser(ruleProvider);
                                    
                                    
                                    
                                
With the new version i have optimize this issue
var httpClient = new HttpClient();
var cacheProvider = new Nager.PublicSuffix.RuleProviders.CacheProviders.LocalFileSystemCacheProvider();
var ruleProvider = new CachedHttpRuleProvider(cacheProvider, httpClient);
await ruleProvider.BuildAsync();
var domainParser = new DomainParser(ruleProvider);
                                    
                                    
                                    
                                
Thanks, since it was use case prominently shown before, assuming indeed a lot of users just took advantage of the earlier one-liner, wouldn't it make sense to still expose a WebTldRuleProvider class (at least for retrocompatibility), or maybe add a SimpleCachedHttpRuleProvider?
I will include the example in the documentation.