Skip to content

Commit 81aa00c

Browse files
committed
include all subdomains
1 parent 6c1f58e commit 81aa00c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ It is possible to apply custom rules to modify the response. This can be used to
120120
See in [ruleset.yaml](ruleset.yaml) for an example.
121121

122122
```yaml
123-
- domain: www.example.com
123+
- domain: example.com # Inbcludes all subdomains
124124
domains: # Additional domains to apply the rule
125-
- www.example.com
125+
- www.example.de
126126
- www.beispiel.de
127127
headers:
128128
x-forwarded-for: none # override X-Forwarded-For header or delete with none
129-
referer: none # override Referer header or delete with none
129+
referer: none # override Referer header or delete with none
130130
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
131131
cookie: privacy=1
132132
regexRules:

handlers/proxy.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,11 @@ func fetchRule(domain string, path string) Rule {
209209
rule := Rule{}
210210
for _, rule := range rulesSet {
211211
domains := rule.Domains
212-
domains = append(domains, rule.Domain)
212+
if rule.Domain != "" {
213+
domains = append(domains, rule.Domain)
214+
}
213215
for _, ruleDomain := range domains {
214-
if ruleDomain == domain {
216+
if ruleDomain == domain || strings.HasSuffix(domain, ruleDomain) {
215217
if len(rule.Paths) > 0 && !StringInSlice(path, rule.Paths) {
216218
continue
217219
}

handlers/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Regex struct {
88
type RuleSet []Rule
99

1010
type Rule struct {
11-
Domain string `yaml:"domain"`
11+
Domain string `yaml:"domain,omitempty"`
1212
Domains []string `yaml:"domains,omitempty"`
1313
Paths []string `yaml:"paths,omitempty"`
1414
Headers struct {

ruleset.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- domain: www.example.com
1+
- domain: example.com
22
domains:
33
- www.beispiel.de
44
googleCache: true
@@ -156,9 +156,7 @@
156156
headimage.forEach(image => { image.style.filter = ''; });
157157
});
158158
</script>
159-
- domain: www.medium.com
160-
domains:
161-
- medium.com
159+
- domain: medium.com
162160
headers:
163161
referer: https://t.co/x?amp=1
164162
x-forwarded-for: none

0 commit comments

Comments
 (0)