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

Side by Side Diff: lib/matcher.js

Issue 29907586: Issue 6994 - Use shortcut matching for location only filters (Closed)
Patch Set: Created Oct. 12, 2018, 4:56 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
« no previous file with comments | « no previous file | 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 * @param {boolean} [specificOnly] 165 * @param {boolean} [specificOnly]
166 * @returns {?Filter} 166 * @returns {?Filter}
167 */ 167 */
168 _checkEntryMatch(keyword, location, typeMask, docDomain, thirdParty, sitekey, 168 _checkEntryMatch(keyword, location, typeMask, docDomain, thirdParty, sitekey,
169 specificOnly) 169 specificOnly)
170 { 170 {
171 let set = this.filterByKeyword.get(keyword); 171 let set = this.filterByKeyword.get(keyword);
172 if (typeof set == "undefined") 172 if (typeof set == "undefined")
173 return null; 173 return null;
174 174
175 for (let filter of set) 175 for (let filter of set)
Manish Jethani 2018/10/13 13:28:45 The idea was to have two loops, one for the locati
Jon Sonesen 2018/10/20 23:07:55 Ack
176 { 176 {
177 if (typeMask == 0)
178 continue;
179
177 if (specificOnly && filter.isGeneric() && 180 if (specificOnly && filter.isGeneric() &&
178 !(filter instanceof WhitelistFilter)) 181 !(filter instanceof WhitelistFilter))
179 continue; 182 continue;
180 183
184 if (!sitekey || !docDomain || !thirdParty)
185 {
Manish Jethani 2018/10/13 13:28:45 This seems wrong.
Jon Sonesen 2018/10/20 23:07:55 Yeah, super wrong. My bad
186 if (filter.matches(location))
187 return filter;
188 }
189
181 if (filter.matches(location, typeMask, docDomain, thirdParty, sitekey)) 190 if (filter.matches(location, typeMask, docDomain, thirdParty, sitekey))
182 return filter; 191 return filter;
183 } 192 }
184 return null; 193 return null;
185 } 194 }
186 195
187 /** 196 /**
188 * Tests whether the URL matches any of the known filters 197 * Tests whether the URL matches any of the known filters
189 * @param {string} location 198 * @param {string} location
190 * URL to be tested 199 * URL to be tested
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 376
368 exports.CombinedMatcher = CombinedMatcher; 377 exports.CombinedMatcher = CombinedMatcher;
369 378
370 /** 379 /**
371 * Shared {@link CombinedMatcher} instance that should usually be used. 380 * Shared {@link CombinedMatcher} instance that should usually be used.
372 * @type {CombinedMatcher} 381 * @type {CombinedMatcher}
373 */ 382 */
374 let defaultMatcher = new CombinedMatcher(); 383 let defaultMatcher = new CombinedMatcher();
375 384
376 exports.defaultMatcher = defaultMatcher; 385 exports.defaultMatcher = defaultMatcher;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld