| 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 16 matching lines...) Expand all Loading... |
| 27 * and "data:" URLs) it falls back to the parent frame. | 27 * and "data:" URLs) it falls back to the parent frame. |
| 28 * | 28 * |
| 29 * @param {?Frame} frame | 29 * @param {?Frame} frame |
| 30 * @param {URL} [originUrl] | 30 * @param {URL} [originUrl] |
| 31 * @return {string} | 31 * @return {string} |
| 32 */ | 32 */ |
| 33 exports.extractHostFromFrame = (frame, originUrl) => | 33 exports.extractHostFromFrame = (frame, originUrl) => |
| 34 { | 34 { |
| 35 for (; frame; frame = frame.parent) | 35 for (; frame; frame = frame.parent) |
| 36 { | 36 { |
| 37 let hostname = frame.url.hostname; | 37 let {hostname} = frame.url; |
| 38 if (hostname) | 38 if (hostname) |
| 39 return hostname; | 39 return hostname; |
| 40 } | 40 } |
| 41 | 41 |
| 42 return originUrl ? originUrl.hostname : ""; | 42 return originUrl ? originUrl.hostname : ""; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 function isDomain(hostname) | 45 function isDomain(hostname) |
| 46 { | 46 { |
| 47 // No hostname or IPv4 address, also considering hexadecimal octets. | 47 // No hostname or IPv4 address, also considering hexadecimal octets. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 66 documentHost = documentHost.replace(/\.+$/, ""); | 66 documentHost = documentHost.replace(/\.+$/, ""); |
| 67 | 67 |
| 68 if (requestHost == documentHost) | 68 if (requestHost == documentHost) |
| 69 return false; | 69 return false; |
| 70 | 70 |
| 71 if (!isDomain(requestHost) || !isDomain(documentHost)) | 71 if (!isDomain(requestHost) || !isDomain(documentHost)) |
| 72 return true; | 72 return true; |
| 73 | 73 |
| 74 return getDomain(requestHost) != getDomain(documentHost); | 74 return getDomain(requestHost) != getDomain(documentHost); |
| 75 }; | 75 }; |
| OLD | NEW |