| 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 27 matching lines...) Expand all Loading... |
| 38 return hostname; | 38 return hostname; |
| 39 | 39 |
| 40 return punycode.toUnicode(hostname); | 40 return punycode.toUnicode(hostname); |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Gets the IDN-decoded hostname from the URL of a frame. | 44 * Gets the IDN-decoded hostname from the URL of a frame. |
| 45 * If the URL don't have host information (like "about:blank" | 45 * If the URL don't have host information (like "about:blank" |
| 46 * and "data:" URLs) it falls back to the parent frame. | 46 * and "data:" URLs) it falls back to the parent frame. |
| 47 * | 47 * |
| 48 * @param {Frame} frame | 48 * @param {?Frame} frame |
| 49 * @param {URL} [originUrl] |
| 49 * @return {string} | 50 * @return {string} |
| 50 */ | 51 */ |
| 51 exports.extractHostFromFrame = frame => | 52 exports.extractHostFromFrame = (frame, originUrl) => |
| 52 { | 53 { |
| 53 for (; frame; frame = frame.parent) | 54 for (; frame; frame = frame.parent) |
| 54 { | 55 { |
| 55 let hostname = getDecodedHostname(frame.url); | 56 let hostname = getDecodedHostname(frame.url); |
| 56 if (hostname) | 57 if (hostname) |
| 57 return hostname; | 58 return hostname; |
| 58 } | 59 } |
| 59 | 60 |
| 60 return ""; | 61 return originUrl ? getDecodedHostname(originUrl) : ""; |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 /** | 64 /** |
| 64 * Converts a URL object into a string. For HTTP(S) URLs | 65 * Converts a URL object into a string. For HTTP(S) URLs |
| 65 * the hostname gets IDN-decoded and the hash is stripped. | 66 * the hostname gets IDN-decoded and the hash is stripped. |
| 66 * | 67 * |
| 67 * @param {URL} url | 68 * @param {URL} url |
| 68 * @return {string} | 69 * @return {string} |
| 69 */ | 70 */ |
| 70 exports.stringifyURL = url => | 71 exports.stringifyURL = url => |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 documentHost = documentHost.replace(/\.+$/, ""); | 110 documentHost = documentHost.replace(/\.+$/, ""); |
| 110 | 111 |
| 111 if (requestHost == documentHost) | 112 if (requestHost == documentHost) |
| 112 return false; | 113 return false; |
| 113 | 114 |
| 114 if (!isDomain(requestHost) || !isDomain(documentHost)) | 115 if (!isDomain(requestHost) || !isDomain(documentHost)) |
| 115 return true; | 116 return true; |
| 116 | 117 |
| 117 return getDomain(requestHost) != getDomain(documentHost); | 118 return getDomain(requestHost) != getDomain(documentHost); |
| 118 }; | 119 }; |
| OLD | NEW |