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

Side by Side Diff: test/filterClasses.js

Issue 29791555: Issue 6727 - Use string rather than map for single-domain filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created May 26, 2018, 10:52 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 result.push("type=comment"); 64 result.push("type=comment");
65 else if (filter instanceof ActiveFilter) 65 else if (filter instanceof ActiveFilter)
66 { 66 {
67 result.push("disabled=" + filter.disabled); 67 result.push("disabled=" + filter.disabled);
68 result.push("lastHit=" + filter.lastHit); 68 result.push("lastHit=" + filter.lastHit);
69 result.push("hitCount=" + filter.hitCount); 69 result.push("hitCount=" + filter.hitCount);
70 70
71 let domains = []; 71 let domains = [];
72 if (filter.domains) 72 if (filter.domains)
73 { 73 {
74 for (let [domain, isIncluded] of filter.domains) 74 if (typeof filter.domains == "string")
75 { 75 {
76 if (domain != "") 76 domains.push(filter.domains);
77 domains.push(isIncluded ? domain : "~" + domain); 77 }
78 else
79 {
80 for (let [domain, isIncluded] of filter.domains)
81 {
82 if (domain != "")
83 domains.push(isIncluded ? domain : "~" + domain);
84 }
78 } 85 }
79 } 86 }
80 result.push("domains=" + domains.sort().join("|")); 87 result.push("domains=" + domains.sort().join("|"));
81 88
82 if (filter instanceof RegExpFilter) 89 if (filter instanceof RegExpFilter)
83 { 90 {
84 result.push("regexp=" + filter.regexp.source); 91 result.push("regexp=" + filter.regexp.source);
85 result.push("contentType=" + filter.contentType); 92 result.push("contentType=" + filter.contentType);
86 result.push("matchCase=" + filter.matchCase); 93 result.push("matchCase=" + filter.matchCase);
87 94
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 filterRelative.rewriteUrl("http://content.server/file/foo.txt?bar"), 545 filterRelative.rewriteUrl("http://content.server/file/foo.txt?bar"),
539 "http://content.server/file/foo.txt/disable" 546 "http://content.server/file/foo.txt/disable"
540 ); 547 );
541 test.equal( 548 test.equal(
542 filterRelative.rewriteUrl("http://example.com/file/foo.txt?bar"), 549 filterRelative.rewriteUrl("http://example.com/file/foo.txt?bar"),
543 "http://example.com/file/foo.txt/disable" 550 "http://example.com/file/foo.txt/disable"
544 ); 551 );
545 552
546 test.done(); 553 test.done();
547 }; 554 };
OLDNEW
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld