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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 { | 33 { |
34 let map = new Map(); | 34 let map = new Map(); |
35 | 35 |
36 for (let key in publicSuffixes) | 36 for (let key in publicSuffixes) |
37 map.set(key, publicSuffixes[key]); | 37 map.set(key, publicSuffixes[key]); |
38 | 38 |
39 return map; | 39 return map; |
40 } | 40 } |
41 | 41 |
42 /** | 42 /** |
| 43 * Normalizes a hostname. |
| 44 * @param {string} hostname |
| 45 * @returns {string} |
| 46 */ |
| 47 function normalizeHostname(hostname) |
| 48 { |
| 49 return (hostname[hostname.length - 1] == "." ? |
| 50 hostname.replace(/\.+$/, "") : hostname).toLowerCase(); |
| 51 } |
| 52 |
| 53 exports.normalizeHostname = normalizeHostname; |
| 54 |
| 55 /** |
43 * Yields all suffixes for a domain. For example, given the domain | 56 * Yields all suffixes for a domain. For example, given the domain |
44 * <code>www.example.com</code>, this function yields | 57 * <code>www.example.com</code>, this function yields |
45 * <code>www.example.com</code>, <code>example.com</code>, and | 58 * <code>www.example.com</code>, <code>example.com</code>, and |
46 * <code>com</code>, in that order. | 59 * <code>com</code>, in that order. |
47 * | 60 * |
48 * @param {string} domain The domain. | 61 * @param {string} domain The domain. |
49 * @param {boolean} [includeBlank] Whether to include the blank suffix at the | 62 * @param {boolean} [includeBlank] Whether to include the blank suffix at the |
50 * end. | 63 * end. |
51 * | 64 * |
52 * @yields {string} The next suffix for the domain. | 65 * @yields {string} The next suffix for the domain. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 if (requestHostname == documentHostname) | 153 if (requestHostname == documentHostname) |
141 return false; | 154 return false; |
142 | 155 |
143 if (!isDomain(requestHostname) || !isDomain(documentHostname)) | 156 if (!isDomain(requestHostname) || !isDomain(documentHostname)) |
144 return true; | 157 return true; |
145 | 158 |
146 return getDomain(requestHostname) != getDomain(documentHostname); | 159 return getDomain(requestHostname) != getDomain(documentHostname); |
147 } | 160 } |
148 | 161 |
149 exports.isThirdParty = isThirdParty; | 162 exports.isThirdParty = isThirdParty; |
OLD | NEW |