Fix a bug which will cause directly-added rules to not appear in Clash subscriptions.

This commit is contained in:
Tindy X
2019-11-20 00:49:17 +08:00
parent 769706d0d0
commit a68363e108
2 changed files with 5 additions and 5 deletions

View File

@@ -83,7 +83,7 @@ std::string refreshRulesets()
if(rule_url.find("[]") == 0) if(rule_url.find("[]") == 0)
{ {
std::cerr<<"Adding rule '"<<rule_url.substr(2)<<","<<rule_group<<"'."<<std::endl; std::cerr<<"Adding rule '"<<rule_url.substr(2)<<","<<rule_group<<"'."<<std::endl;
rc = {rule_group, rule_url}; rc = {rule_group, "", rule_url};
ruleset_content_array.emplace_back(rc); ruleset_content_array.emplace_back(rc);
continue; continue;
} }

View File

@@ -288,10 +288,10 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
for(ruleset_content &x : ruleset_content_array) for(ruleset_content &x : ruleset_content_array)
{ {
rule_group = x.rule_group; rule_group = x.rule_group;
rule_path = x.rule_path; retrived_rules = x.rule_content;
if(rule_path.find("[]") == 0) if(retrived_rules.find("[]") == 0)
{ {
strLine = rule_path.substr(2); strLine = retrived_rules.substr(2);
if(strLine == "MATCH") if(strLine == "MATCH")
strLine = "FINAL"; strLine = "FINAL";
allRules.emplace_back(strLine + "," + rule_group); allRules.emplace_back(strLine + "," + rule_group);
@@ -299,6 +299,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
} }
else else
{ {
rule_path = x.rule_path;
if(!fileExist(rule_path)) if(!fileExist(rule_path))
{ {
if(surge_ver > 2) if(surge_ver > 2)
@@ -308,7 +309,6 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
} }
} }
retrived_rules = x.rule_content;
char delimiter = count(retrived_rules.begin(), retrived_rules.end(), '\n') < 1 ? '\r' : '\n'; char delimiter = count(retrived_rules.begin(), retrived_rules.end(), '\n') < 1 ? '\r' : '\n';
strStrm.clear(); strStrm.clear();