Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: abp2blocklist.js

Issue 29328931: Issue 3176 - Keep filter list parameters (Closed)
Patch Set: Created Oct. 7, 2015, 7:49 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: abp2blocklist.js
===================================================================
--- a/abp2blocklist.js
+++ b/abp2blocklist.js
@@ -5,6 +5,7 @@
var typeMap = filterClasses.RegExpFilter.typeMap;
+var params = {};
var requestFilters = [];
var requestExceptions = [];
var elemhideFilters = [];
@@ -69,6 +70,18 @@
recordSelectorException(filter);
}
+function parseLine(line) {
+ var paramMatch = /^\s*!\s*([\w ]+)\s*:\s*(.*)/.exec(line);
Sebastian Noack 2015/10/13 11:25:08 I think we should leave the parsing to the core co
+ if (paramMatch) {
+ var key = paramMatch[1];
+ var paramsToKeep = ["version", "title", "last modified", "expires", "homepage", "licence"];
+ if (paramsToKeep.indexOf(key.toLowerCase()) != -1)
+ params[key] = paramMatch[2];
+ return;
+ }
+ parseFilter(line);
+}
+
function escapeRegExp(s) {
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
@@ -265,9 +278,12 @@
for (i = 0; i < requestExceptions.length; i++)
addRule(convertFilter(requestExceptions[i], "ignore-previous-rules", true));
+ for (key in params)
+ if (params.hasOwnProperty(key))
+ console.log("// " + key + ": " + params[key]);
Sebastian Noack 2015/10/13 11:25:08 But anyway, valid JSON cannot have comments. So NO
Felix Dahlke 2015/10/13 11:37:26 Did you read https://issues.adblockplus.org/ticket
Felix Dahlke 2015/10/13 11:52:15 But well, different approaches shouldn't be discus
console.log(JSON.stringify(rules, null, "\t"));
}
var rl = readline.createInterface({input: process.stdin, terminal: false});
-rl.on("line", parseFilter);
+rl.on("line", parseLine);
rl.on("close", logRules);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld