include all subdomains

This commit is contained in:
Gianni Carafa
2023-11-09 23:51:36 +01:00
parent 6c1f58e2e7
commit 81aa00c2ea
4 changed files with 10 additions and 10 deletions

View File

@@ -120,9 +120,9 @@ It is possible to apply custom rules to modify the response. This can be used to
See in [ruleset.yaml](ruleset.yaml) for an example.
```yaml
- domain: www.example.com
- domain: example.com # Inbcludes all subdomains
domains: # Additional domains to apply the rule
- www.example.com
- www.example.de
- www.beispiel.de
headers:
x-forwarded-for: none # override X-Forwarded-For header or delete with none

View File

@@ -209,9 +209,11 @@ func fetchRule(domain string, path string) Rule {
rule := Rule{}
for _, rule := range rulesSet {
domains := rule.Domains
if rule.Domain != "" {
domains = append(domains, rule.Domain)
}
for _, ruleDomain := range domains {
if ruleDomain == domain {
if ruleDomain == domain || strings.HasSuffix(domain, ruleDomain) {
if len(rule.Paths) > 0 && !StringInSlice(path, rule.Paths) {
continue
}

View File

@@ -8,7 +8,7 @@ type Regex struct {
type RuleSet []Rule
type Rule struct {
Domain string `yaml:"domain"`
Domain string `yaml:"domain,omitempty"`
Domains []string `yaml:"domains,omitempty"`
Paths []string `yaml:"paths,omitempty"`
Headers struct {

View File

@@ -1,4 +1,4 @@
- domain: www.example.com
- domain: example.com
domains:
- www.beispiel.de
googleCache: true
@@ -156,9 +156,7 @@
headimage.forEach(image => { image.style.filter = ''; });
});
</script>
- domain: www.medium.com
domains:
- medium.com
- domain: medium.com
headers:
referer: https://t.co/x?amp=1
x-forwarded-for: none