Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 | 99 |
100 let host = getDecodedHostname(url); | 100 let host = getDecodedHostname(url); |
101 if (url.port) | 101 if (url.port) |
102 host += ":" + url.port; | 102 host += ":" + url.port; |
103 return protocol + "//" + host + url.pathname + url.search; | 103 return protocol + "//" + host + url.pathname + url.search; |
104 } | 104 } |
105 exports.stringifyURL = stringifyURL; | 105 exports.stringifyURL = stringifyURL; |
106 | 106 |
107 function isDomain(hostname) | 107 function isDomain(hostname) |
108 { | 108 { |
109 // IPv4 address, also considering hexadecimal octets. | 109 // No hostname or IPv4 address, also considering hexadecimal octets. |
110 if (/^((0x[\da-f]+|\d+)(\.|$)){4}$/i.test(hostname)) | 110 if (/^((0x[\da-f]+|\d+)(\.|$))*$/i.test(hostname)) |
Wladimir Palant
2015/02/11 13:45:45
This won't accept "0x5bec7a38" - should be {1,4} I
Sebastian Noack
2015/02/11 17:07:06
Even better; arbitrary and optional. So we also ba
| |
111 return false; | 111 return false; |
112 | 112 |
113 // IPv6 address. Since there can't be colons in domains, we can | 113 // IPv6 address. Since there can't be colons in domains, we can |
114 // just check whether there are any colons to exclude IPv6 addresses. | 114 // just check whether there are any colons to exclude IPv6 addresses. |
115 return hostname.indexOf(":") == -1; | 115 return hostname.indexOf(":") == -1; |
116 } | 116 } |
117 | 117 |
118 function getBaseDomain(hostname) | 118 function getBaseDomain(hostname) |
119 { | 119 { |
120 let bits = hostname.split("."); | 120 let bits = hostname.split("."); |
(...skipping 30 matching lines...) Expand all Loading... | |
151 | 151 |
152 if (requestHost == documentHost) | 152 if (requestHost == documentHost) |
153 return false; | 153 return false; |
154 | 154 |
155 if (!isDomain(requestHost) || !isDomain(documentHost)) | 155 if (!isDomain(requestHost) || !isDomain(documentHost)) |
156 return true; | 156 return true; |
157 | 157 |
158 return getBaseDomain(requestHost) != getBaseDomain(documentHost); | 158 return getBaseDomain(requestHost) != getBaseDomain(documentHost); |
159 } | 159 } |
160 exports.isThirdParty = isThirdParty; | 160 exports.isThirdParty = isThirdParty; |
LEFT | RIGHT |