diff --git a/README.md b/README.md index 3fede33..334d92b 100644 --- a/README.md +++ b/README.md @@ -120,13 +120,13 @@ 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 - referer: none # override Referer header or delete with none + referer: none # override Referer header or delete with none user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 cookie: privacy=1 regexRules: diff --git a/handlers/proxy.go b/handlers/proxy.go index 67edbee..8862492 100644 --- a/handlers/proxy.go +++ b/handlers/proxy.go @@ -209,9 +209,11 @@ func fetchRule(domain string, path string) Rule { rule := Rule{} for _, rule := range rulesSet { domains := rule.Domains - domains = append(domains, rule.Domain) + 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 } diff --git a/handlers/types.go b/handlers/types.go index eacc722..5aca088 100644 --- a/handlers/types.go +++ b/handlers/types.go @@ -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 { diff --git a/ruleset.yaml b/ruleset.yaml index bf8b346..1fe50e3 100644 --- a/ruleset.yaml +++ b/ruleset.yaml @@ -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 = ''; }); }); -- domain: www.medium.com - domains: - - medium.com +- domain: medium.com headers: referer: https://t.co/x?amp=1 x-forwarded-for: none