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

Side by Side Diff: lib/filterClasses.js

Issue 29926557: Issue 6994 - Use shortcut matching for location-only filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Minor update Created Oct. 25, 2018, 9:22 p.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 | lib/matcher.js » ('j') | 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 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 { 846 {
847 let index = location.indexOf(pattern.substring(2)); 847 let index = location.indexOf(pattern.substring(2));
848 848
849 // The "||" prefix requires that the text that follows does not start 849 // The "||" prefix requires that the text that follows does not start
850 // with a forward slash. 850 // with a forward slash.
851 return index != -1 && location[index] != "/" && 851 return index != -1 && location[index] != "/" &&
852 doubleAnchorRegExp.test(location.substring(0, index)); 852 doubleAnchorRegExp.test(location.substring(0, index));
853 } 853 }
854 854
855 return location.includes(pattern); 855 return location.includes(pattern);
856 },
857
858 /**
859 * Checks whether this filter has only a URL pattern and no content type,
860 * third-party flag, domains, or sitekeys.
861 * @returns {boolean}
862 */
863 isLocationOnly()
864 {
865 return this.contentType == RegExpFilter.prototype.contentType &&
866 this.thirdParty == null &&
867 !this.domainSource && !this.sitekeySource &&
868 !this.domains && !this.sitekeys;
856 } 869 }
857 }); 870 });
858 871
859 /** 872 /**
860 * Yields the filter itself (required to optimize {@link Matcher}). 873 * Yields the filter itself (required to optimize {@link Matcher}).
861 * @yields {RegExpFilter} 874 * @yields {RegExpFilter}
862 */ 875 */
863 RegExpFilter.prototype[Symbol.iterator] = function*() 876 RegExpFilter.prototype[Symbol.iterator] = function*()
864 { 877 {
865 yield this; 878 yield this;
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 1353
1341 /** 1354 /**
1342 * Script that should be executed 1355 * Script that should be executed
1343 * @type {string} 1356 * @type {string}
1344 */ 1357 */
1345 get script() 1358 get script()
1346 { 1359 {
1347 return this.body; 1360 return this.body;
1348 } 1361 }
1349 }); 1362 });
OLDNEW
« no previous file with comments | « no previous file | lib/matcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld