OLD | NEW |
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 "use strict"; | 18 "use strict"; |
19 | 19 |
20 /** | 20 /** |
21 * @fileOverview Matcher class implementing matching addresses against | 21 * @fileOverview Matcher class implementing matching addresses against |
22 * a list of filters. | 22 * a list of filters. |
23 */ | 23 */ |
24 | 24 |
25 const {RegExpFilter, WhitelistFilter} = require("./filterClasses"); | 25 const {RegExpFilter, WhitelistFilter} = require("./filterClasses"); |
26 const {normalizeHostname, suffixes} = require("./domain"); | 26 const {normalizeHostname, domainSuffixes} = require("./url"); |
27 const {Cache} = require("./caching"); | 27 const {Cache} = require("./caching"); |
28 | 28 |
29 /** | 29 /** |
30 * Regular expression for matching a keyword in a filter. | 30 * Regular expression for matching a keyword in a filter. |
31 * @type {RegExp} | 31 * @type {RegExp} |
32 */ | 32 */ |
33 const keywordRegExp = /[^a-z0-9%*][a-z0-9%]{3,}(?=[^a-z0-9%*])/; | 33 const keywordRegExp = /[^a-z0-9%*][a-z0-9%]{3,}(?=[^a-z0-9%*])/; |
34 | 34 |
35 /** | 35 /** |
36 * Regular expression for matching all keywords in a filter. | 36 * Regular expression for matching all keywords in a filter. |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 return filtersByDomain; | 495 return filtersByDomain; |
496 | 496 |
497 collection.push(filtersByDomain); | 497 collection.push(filtersByDomain); |
498 } | 498 } |
499 | 499 |
500 return null; | 500 return null; |
501 } | 501 } |
502 | 502 |
503 let excluded = new Set(); | 503 let excluded = new Set(); |
504 | 504 |
505 for (let suffix of suffixes(docDomain ? normalizeHostname(docDomain) : "", | 505 for (let suffix of domainSuffixes(docDomain ? |
506 !specificOnly)) | 506 normalizeHostname(docDomain) : "", |
| 507 !specificOnly)) |
507 { | 508 { |
508 let filters = filtersByDomain.get(suffix); | 509 let filters = filtersByDomain.get(suffix); |
509 if (filters) | 510 if (filters) |
510 { | 511 { |
511 for (let [filter, include] of filters.entries()) | 512 for (let [filter, include] of filters.entries()) |
512 { | 513 { |
513 if (!include) | 514 if (!include) |
514 { | 515 { |
515 excluded.add(filter); | 516 excluded.add(filter); |
516 } | 517 } |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 | 876 |
876 exports.CombinedMatcher = CombinedMatcher; | 877 exports.CombinedMatcher = CombinedMatcher; |
877 | 878 |
878 /** | 879 /** |
879 * Shared {@link CombinedMatcher} instance that should usually be used. | 880 * Shared {@link CombinedMatcher} instance that should usually be used. |
880 * @type {CombinedMatcher} | 881 * @type {CombinedMatcher} |
881 */ | 882 */ |
882 let defaultMatcher = new CombinedMatcher(); | 883 let defaultMatcher = new CombinedMatcher(); |
883 | 884 |
884 exports.defaultMatcher = defaultMatcher; | 885 exports.defaultMatcher = defaultMatcher; |
OLD | NEW |