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

Side by Side Diff: qunit/tests/baseDomain.js

Issue 5564089086509056: Issue 1801 - Use URL objects to process URLs in the background page (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « qunit/index.html ('k') | qunit/tests/url.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18
19 (function()
20 {
21 module("URL/host tools");
22
23 test("Host name extraction", function()
24 {
25 var tests = [
26 [null, ""],
27 ["/foo/bar", ""],
28 ["http://example.com", "example.com"],
29 ["http://example.com?foo#bar", "example.com"],
30 ["http://example.com#foo?bar", "example.com"],
31 ["http://example.com/", "example.com"],
32 ["http://example.com:8000/", "example.com"],
33 ["http://foo:bar@example.com:8000/foo:bar/bas", "example.com"],
34 ["ftp://example.com/", "example.com"],
35 ["http://1.2.3.4:8000/", "1.2.3.4"],
36 ["http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/", "2001:0db8:85a3:0000 :0000:8a2e:0370:7334"],
37 ["http://[2001::7334]:8000/test@foo.example.com/bar", "2001::7334"],
38 ];
39
40 for (var i = 0; i < tests.length; i++)
41 equal(extractHostFromURL(tests[i][0]), tests[i][1], tests[i][0]);
42 });
43
44 test("Determining base domain", function()
45 {
46 var tests = [
47 ["com", "com"],
48 ["example.com", "example.com"],
49 ["www.example.com", "example.com"],
50 ["www.example.com.", "example.com"],
51 ["www.example.co.uk", "example.co.uk"],
52 ["www.example.co.uk.", "example.co.uk"],
53 ["www.example.bl.uk", "bl.uk"],
54 ["foo.bar.example.co.uk", "example.co.uk"],
55 ["1.2.3.4.com", "4.com"],
56 ["1.2.3.4.bg", "3.4.bg"],
57 ["1.2.3.4", "1.2.3.4"],
58 ["1.2.0x3.0x4", "1.2.0x3.0x4"],
59 ["1.2.3", "2.3"],
60 ["1.2.0x3g.0x4", "0x3g.0x4"],
61 ["2001:0db8:85a3:0000:0000:8a2e:0370:7334", "2001:0db8:85a3:0000:0000:8a2e :0370:7334"],
62 ["2001::7334", "2001::7334"],
63 ["::ffff:1.2.3.4", "::ffff:1.2.3.4"],
64 ["foo.bar.2001::7334", "bar.2001::7334"],
65 ["test.xn--e1aybc.xn--p1ai", "тест.рф"],
66 ];
67
68 for (var i = 0; i < tests.length; i++)
69 equal(getBaseDomain(tests[i][0]), tests[i][1], tests[i][0]);
70 });
71
72 test("Third party checks", function()
73 {
74 var tests = [
75 ["foo", "foo", false],
76 ["foo", "bar", true],
77 ["foo.com", "bar.com", true],
78 ["foo.com", "foo.com", false],
79 ["foo.com", "www.foo.com", false],
80 ["foo.example.com", "bar.example.com", false],
81 ["foo.uk", "bar.uk", true],
82 ["foo.co.uk", "bar.co.uk", true],
83 ["foo.example.co.uk", "bar.example.co.uk", false],
84 ["1.2.3.4", "2.2.3.4", true],
85 ];
86
87 for (var i = 0; i < tests.length; i++)
88 equal(isThirdParty(tests[i][0], tests[i][1]), tests[i][2], tests[i][0] + " and " + tests[i][1]);
89 });
90 })();
OLDNEW
« no previous file with comments | « qunit/index.html ('k') | qunit/tests/url.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld