This commit is contained in:
Gianni Carafa
2023-11-03 15:34:41 +01:00
parent d34c5680b3
commit d5c58f42da
2 changed files with 16 additions and 24 deletions

View File

@@ -116,7 +116,7 @@ func loadRules() RuleSet {
return RulesList
}
log.Println("Loading rules")
// TODO: Load the rules from the URL
resp, err := http.Get(rulesUrl)
if err != nil {
log.Println("ERROR:", err)
@@ -149,10 +149,11 @@ func applyRules(domain string, path string, body string) string {
if rule.Path != "" && rule.Path != path {
continue
}
for _, domRule := range rule.DomRules {
re := regexp.MustCompile(domRule.Match)
body = re.ReplaceAllString(body, domRule.Replace)
}
/*
for _, domRule := range rule.DomRules {
// run the dom rules
}
*/
for _, regexRule := range rule.RegexRules {
re := regexp.MustCompile(regexRule.Match)
body = re.ReplaceAllString(body, regexRule.Replace)

View File

@@ -1,24 +1,15 @@
- domain: www.example.ch
- domain: www.example.com
path: /article
regexRules:
- match: "asdf"
replace: "asdf"
- match: "asdf"
replace: "asdf"
- match: <script\s+([^>]*\s+)?src="(/)([^"]*)"
replace: <script $1 script="/https://www.example.com/$3"
domRules:
- match: "asdf"
replace: "asdf"
- match: "asdf"
replace: "asdf"
- domain: www.srf.ch
path: /article
- match: "tobe.defined"
replace: "test"
- domain: www.anotherdomain.com
regexRules:
- match: "asdf"
replace: "asdf"
- match: "asdf"
replace: "asdf"
- match: <script\s+([^>]*\s+)?src="(/)([^"]*)"
replace: <script $1 script="/https://www.example.com/$3"
domRules:
- match: "asdf"
replace: "asdf"
- match: "asdf"
replace: "asdf"
- match: "tobe.defined"
replace: "test"