-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPublicSuffixListProviderBase.cs
More file actions
39 lines (26 loc) · 1.04 KB
/
PublicSuffixListProviderBase.cs
File metadata and controls
39 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
namespace Gsemac.Net {
public abstract class PublicSuffixListProviderBase :
IPublicSuffixListProvider {
// Public members
public TimeSpan TimeToLive { get; set; } = default;
public bool FallbackEnabled { get; set; } = true;
public virtual IPublicSuffixList GetList() {
return new ResourcePublicSuffixListProvider().GetList();
}
// Protected members
protected static IEnumerable<string> ParseList(string list) {
if (string.IsNullOrWhiteSpace(list))
return Enumerable.Empty<string>();
IEnumerable<string> suffixes = list
.Split(new[] { '\n' }, StringSplitOptions.None)
.Where(x => !string.IsNullOrWhiteSpace(x) && !x.StartsWith("//"))
.Select(x => '.' + x.TrimStart('*', '!', '.').Trim())
.OrderByDescending(x => x.Length)
.ToArray();
return suffixes;
}
}
}