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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 "use strict"; | 18 "use strict"; |
19 | 19 |
20 { | 20 { |
21 let url = require("url"); | 21 let {getDecodedHostname, |
Sebastian Noack
2017/01/16 15:35:57
I suppose we could better use destructuring here n
kzar
2017/01/17 07:42:50
Done.
| |
22 let getDecodedHostname = url.getDecodedHostname; | 22 extractHostFromFrame, |
23 let extractHostFromFrame = url.extractHostFromFrame; | 23 stringifyURL, |
24 let stringifyURL = url.stringifyURL; | 24 isThirdParty} = require("url"); |
25 let isThirdParty = url.isThirdParty; | |
26 | 25 |
27 module("URL/host tools"); | 26 module("URL/host tools"); |
28 | 27 |
29 test("Extracting hostname from URL", () => | 28 test("Extracting hostname from URL", () => |
30 { | 29 { |
31 function testURLHostname(url, expectedHostname, message) | 30 function testURLHostname(url, expectedHostname, message) |
32 { | 31 { |
33 equal(getDecodedHostname(new URL(url)), expectedHostname, message); | 32 equal(getDecodedHostname(new URL(url)), expectedHostname, message); |
34 } | 33 } |
35 | 34 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 testThirdParty("1.0xff.1.1", "2.0xff.1.1", true, "different IPv4 address wit h hexadecimal octet is third-party"); | 127 testThirdParty("1.0xff.1.1", "2.0xff.1.1", true, "different IPv4 address wit h hexadecimal octet is third-party"); |
129 testThirdParty("0xff.example.com", "example.com", false, "domain starts like a hexadecimal IPv4 address but isn't one"); | 128 testThirdParty("0xff.example.com", "example.com", false, "domain starts like a hexadecimal IPv4 address but isn't one"); |
130 testThirdParty("[2001:db8:85a3::8a2e:370:7334]", "[2001:db8:85a3::8a2e:370:7 334]", false, "same IPv6 address isn't third-party"); | 129 testThirdParty("[2001:db8:85a3::8a2e:370:7334]", "[2001:db8:85a3::8a2e:370:7 334]", false, "same IPv6 address isn't third-party"); |
131 testThirdParty("[2001:db8:85a3::8a2e:370:7334]", "[5001:db8:85a3::8a2e:370:7 334]", true, "different IPv6 address is third-party"); | 130 testThirdParty("[2001:db8:85a3::8a2e:370:7334]", "[5001:db8:85a3::8a2e:370:7 334]", true, "different IPv6 address is third-party"); |
132 testThirdParty("[::ffff:192.0.2.128]", "[::ffff:192.0.2.128]", false, "same IPv4-mapped IPv6 address isn't third-party"); | 131 testThirdParty("[::ffff:192.0.2.128]", "[::ffff:192.0.2.128]", false, "same IPv4-mapped IPv6 address isn't third-party"); |
133 testThirdParty("[::ffff:192.0.2.128]", "[::ffff:192.1.2.128]", true, "differ ent IPv4-mapped IPv6 address is third-party"); | 132 testThirdParty("[::ffff:192.0.2.128]", "[::ffff:192.1.2.128]", true, "differ ent IPv4-mapped IPv6 address is third-party"); |
134 testThirdParty("xn--f-1gaa.com", "f\u00f6\u00f6.com", false, "same IDN isn't third-party"); | 133 testThirdParty("xn--f-1gaa.com", "f\u00f6\u00f6.com", false, "same IDN isn't third-party"); |
135 testThirdParty("example.com..", "example.com....", false, "traling dots are ignored"); | 134 testThirdParty("example.com..", "example.com....", false, "traling dots are ignored"); |
136 }); | 135 }); |
137 } | 136 } |
LEFT | RIGHT |