LEFT | RIGHT |
(no file at all) | |
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 * on a particular host name. | 227 * on a particular host name. |
228 * @param {string} domain | 228 * @param {string} domain |
229 * @param {boolean} [specificOnly] true if generic filters should not apply. | 229 * @param {boolean} [specificOnly] true if generic filters should not apply. |
230 * @returns {string[]} List of selectors. | 230 * @returns {string[]} List of selectors. |
231 */ | 231 */ |
232 getSelectorsForDomain(domain, specificOnly = false) | 232 getSelectorsForDomain(domain, specificOnly = false) |
233 { | 233 { |
234 let selectors = []; | 234 let selectors = []; |
235 | 235 |
236 let excluded = new Set(); | 236 let excluded = new Set(); |
237 let currentDomain = domain ? domain.toUpperCase() : ""; | 237 let currentDomain = domain ? domain.replace(/\.+$/, "").toUpperCase() : ""; |
238 | 238 |
239 // This code is a performance hot-spot, which is why we've made certain | 239 // This code is a performance hot-spot, which is why we've made certain |
240 // micro-optimisations. Please be careful before making changes. | 240 // micro-optimisations. Please be careful before making changes. |
241 while (true) | 241 while (true) |
242 { | 242 { |
243 if (specificOnly && currentDomain == "") | 243 if (specificOnly && currentDomain == "") |
244 break; | 244 break; |
245 | 245 |
246 let filters = filtersByDomain.get(currentDomain); | 246 let filters = filtersByDomain.get(currentDomain); |
247 if (filters) | 247 if (filters) |
(...skipping 18 matching lines...) Expand all Loading... |
266 let nextDot = currentDomain.indexOf("."); | 266 let nextDot = currentDomain.indexOf("."); |
267 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); | 267 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); |
268 } | 268 } |
269 | 269 |
270 if (!specificOnly) | 270 if (!specificOnly) |
271 selectors = getUnconditionalSelectors().concat(selectors); | 271 selectors = getUnconditionalSelectors().concat(selectors); |
272 | 272 |
273 return selectors; | 273 return selectors; |
274 } | 274 } |
275 }; | 275 }; |
LEFT | RIGHT |