Skip to content

Commit a28ca6e

Browse files
committed
prepend + append rules instead of just add
1 parent 0b6e113 commit a28ca6e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

EnvForwarder/rules.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ bool EnvironmentRules::open(const std::string& path)
5454
tokenExpression = line.substr(idxSeparatorRule + 1, -1);
5555
}
5656

57-
if (tokenRule == "+" || tokenRule == "ADD") {
58-
rule.type = RULE_ADD;
57+
if (tokenRule == "+" || tokenRule == "ADD" || tokenRule == "APPEND") {
58+
rule.type = RULE_APPEND;
59+
}
60+
else if (tokenRule == "PREPEND") {
61+
rule.type = RULE_PREPEND;
5962
}
6063
else if (tokenRule == "-" || tokenRule == "REMOVE") {
6164
rule.type = RULE_REMOVE;
@@ -81,7 +84,13 @@ bool EnvironmentRules::open(const std::string& path)
8184
void EnvironmentRules::applyRules(std::string& value, const rules& rules)
8285
{
8386
for (const rule& rule : rules) {
84-
if (rule.type == RULE_ADD) {
87+
if (rule.type == RULE_APPEND) {
88+
if (!value.empty() && !value.ends_with(';')) {
89+
value += ";";
90+
}
91+
value += rule.expression;
92+
}
93+
else if (rule.type == RULE_PREPEND) {
8594
if (!value.empty() && !value.starts_with(';')) {
8695
value = ";" + value;
8796
}

EnvForwarder/rules.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ namespace my
88
enum RuleType
99
{
1010
RULE_INVALID,
11-
RULE_ADD,
11+
RULE_PREPEND,
12+
RULE_APPEND,
1213
RULE_REMOVE
1314
};
1415

0 commit comments

Comments
 (0)