Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/url.js

Issue 5564089086509056: Issue 1801 - Use URL objects to process URLs in the background page (Closed)
Left Patch Set: Rebased and addressed comments Created Feb. 11, 2015, 10:54 a.m.
Right Patch Set: Rebased and addressed comments Created Feb. 11, 2015, 5:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/basedomain.js ('k') | lib/whitelisting.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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
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;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld