Skip to content

Commit 37a9631

Browse files
authored
Non-special URL path tests
Some of these used to be part of #4406. See also whatwg/url#212.
1 parent ca9e906 commit 37a9631

File tree

2 files changed

+187
-14
lines changed

2 files changed

+187
-14
lines changed

url/setters_tests.json

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
"href": "a://example.net",
2828
"new_value": "",
2929
"expected": {
30-
"href": "a://example.net/",
30+
"href": "a://example.net",
3131
"protocol": "a:"
3232
}
3333
},
3434
{
3535
"href": "a://example.net",
3636
"new_value": "b",
3737
"expected": {
38-
"href": "b://example.net/",
38+
"href": "b://example.net",
3939
"protocol": "b:"
4040
}
4141
},
@@ -44,7 +44,7 @@
4444
"href": "a://example.net",
4545
"new_value": "B",
4646
"expected": {
47-
"href": "b://example.net/",
47+
"href": "b://example.net",
4848
"protocol": "b:"
4949
}
5050
},
@@ -53,7 +53,7 @@
5353
"href": "a://example.net",
5454
"new_value": "é",
5555
"expected": {
56-
"href": "a://example.net/",
56+
"href": "a://example.net",
5757
"protocol": "a:"
5858
}
5959
},
@@ -62,7 +62,7 @@
6262
"href": "a://example.net",
6363
"new_value": "0b",
6464
"expected": {
65-
"href": "a://example.net/",
65+
"href": "a://example.net",
6666
"protocol": "a:"
6767
}
6868
},
@@ -71,15 +71,15 @@
7171
"href": "a://example.net",
7272
"new_value": "+b",
7373
"expected": {
74-
"href": "a://example.net/",
74+
"href": "a://example.net",
7575
"protocol": "a:"
7676
}
7777
},
7878
{
7979
"href": "a://example.net",
8080
"new_value": "bC0+-.",
8181
"expected": {
82-
"href": "bc0+-.://example.net/",
82+
"href": "bc0+-.://example.net",
8383
"protocol": "bc0+-.:"
8484
}
8585
},
@@ -88,7 +88,7 @@
8888
"href": "a://example.net",
8989
"new_value": "b,c",
9090
"expected": {
91-
"href": "a://example.net/",
91+
"href": "a://example.net",
9292
"protocol": "a:"
9393
}
9494
},
@@ -97,7 +97,7 @@
9797
"href": "a://example.net",
9898
"new_value": "",
9999
"expected": {
100-
"href": "a://example.net/",
100+
"href": "a://example.net",
101101
"protocol": "a:"
102102
}
103103
},
@@ -140,23 +140,23 @@
140140
"href": "ssh://[email protected]",
141141
"new_value": "http",
142142
"expected": {
143-
"href": "ssh://[email protected]/",
143+
"href": "ssh://[email protected]",
144144
"protocol": "ssh:"
145145
}
146146
},
147147
{
148148
"href": "ssh://[email protected]",
149149
"new_value": "gopher",
150150
"expected": {
151-
"href": "ssh://[email protected]/",
151+
"href": "ssh://[email protected]",
152152
"protocol": "ssh:"
153153
}
154154
},
155155
{
156156
"href": "ssh://[email protected]",
157157
"new_value": "file",
158158
"expected": {
159-
"href": "ssh://[email protected]/",
159+
"href": "ssh://[email protected]",
160160
"protocol": "ssh:"
161161
}
162162
},
@@ -1278,6 +1278,33 @@
12781278
"href": "http://example.net/%3F",
12791279
"pathname": "/%3F"
12801280
}
1281+
},
1282+
{
1283+
"comment": "# needs to be encoded",
1284+
"href": "http://example.net",
1285+
"new_value": "#",
1286+
"expected": {
1287+
"href": "http://example.net/%23",
1288+
"pathname": "/%23"
1289+
}
1290+
},
1291+
{
1292+
"comment": "? needs to be encoded, non-special scheme",
1293+
"href": "sc://example.net",
1294+
"new_value": "?",
1295+
"expected": {
1296+
"href": "sc://example.net/%3F",
1297+
"pathname": "/%3F"
1298+
}
1299+
},
1300+
{
1301+
"comment": "# needs to be encoded, non-special scheme",
1302+
"href": "sc://example.net",
1303+
"new_value": "#",
1304+
"expected": {
1305+
"href": "sc://example.net/%23",
1306+
"pathname": "/%23"
1307+
}
12811308
}
12821309
],
12831310
"search": [

url/urltestdata.json

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,15 @@
553553
{
554554
"input": "foo://",
555555
"base": "http://example.org/foo/bar",
556-
"href": "foo:///",
556+
"href": "foo://",
557557
"origin": "null",
558558
"protocol": "foo:",
559559
"username": "",
560560
"password": "",
561561
"host": "",
562562
"hostname": "",
563563
"port": "",
564-
"pathname": "/",
564+
"pathname": "",
565565
"search": "",
566566
"hash": ""
567567
},
@@ -4907,5 +4907,151 @@
49074907
"input": "http://#",
49084908
"base": "about:blank",
49094909
"failure": "true"
4910+
},
4911+
"# Non-special-URL path tests",
4912+
{
4913+
"input": "sc://ñ",
4914+
"base": "about:blank",
4915+
"href": "sc://%C3%B1",
4916+
"origin": "null",
4917+
"protocol": "sc:",
4918+
"username": "",
4919+
"password": "",
4920+
"host": "%C3%B1",
4921+
"hostname": "%C3%B1",
4922+
"port": "",
4923+
"pathname": "",
4924+
"search": "",
4925+
"hash": ""
4926+
},
4927+
{
4928+
"input": "sc://ñ?x",
4929+
"base": "about:blank",
4930+
"href": "sc://%C3%B1?x",
4931+
"origin": "null",
4932+
"protocol": "sc:",
4933+
"username": "",
4934+
"password": "",
4935+
"host": "%C3%B1",
4936+
"hostname": "%C3%B1",
4937+
"port": "",
4938+
"pathname": "",
4939+
"search": "?x",
4940+
"hash": ""
4941+
},
4942+
{
4943+
"input": "sc://ñ#x",
4944+
"base": "about:blank",
4945+
"href": "sc://%C3%B1#x",
4946+
"origin": "null",
4947+
"protocol": "sc:",
4948+
"username": "",
4949+
"password": "",
4950+
"host": "%C3%B1",
4951+
"hostname": "%C3%B1",
4952+
"port": "",
4953+
"pathname": "",
4954+
"search": "",
4955+
"hash": "#x"
4956+
},
4957+
{
4958+
"input": "#x",
4959+
"base": "sc://ñ",
4960+
"href": "sc://%C3%B1#x",
4961+
"origin": "null",
4962+
"protocol": "sc:",
4963+
"username": "",
4964+
"password": "",
4965+
"host": "%C3%B1",
4966+
"hostname": "%C3%B1",
4967+
"port": "",
4968+
"pathname": "",
4969+
"search": "",
4970+
"hash": "#x"
4971+
},
4972+
{
4973+
"input": "?x",
4974+
"base": "sc://ñ",
4975+
"href": "sc://%C3%B1?x",
4976+
"origin": "null",
4977+
"protocol": "sc:",
4978+
"username": "",
4979+
"password": "",
4980+
"host": "%C3%B1",
4981+
"hostname": "%C3%B1",
4982+
"port": "",
4983+
"pathname": "",
4984+
"search": "?x",
4985+
"hash": ""
4986+
},
4987+
{
4988+
"input": "sc://?",
4989+
"base": "about:blank",
4990+
"href": "sc://?",
4991+
"protocol": "sc:",
4992+
"username": "",
4993+
"password": "",
4994+
"host": "",
4995+
"hostname": "",
4996+
"port": "",
4997+
"pathname": "",
4998+
"search": "",
4999+
"hash": ""
5000+
},
5001+
{
5002+
"input": "sc://#",
5003+
"base": "about:blank",
5004+
"href": "sc://#",
5005+
"protocol": "sc:",
5006+
"username": "",
5007+
"password": "",
5008+
"host": "",
5009+
"hostname": "",
5010+
"port": "",
5011+
"pathname": "",
5012+
"search": "",
5013+
"hash": ""
5014+
},
5015+
{
5016+
"input": "///",
5017+
"base": "sc://x/",
5018+
"href": "sc:///",
5019+
"protocol": "sc:",
5020+
"username": "",
5021+
"password": "",
5022+
"host": "",
5023+
"hostname": "",
5024+
"port": "",
5025+
"pathname": "/",
5026+
"search": "",
5027+
"hash": ""
5028+
},
5029+
{
5030+
"input": "////",
5031+
"base": "sc://x/",
5032+
"href": "sc:////",
5033+
"protocol": "sc:",
5034+
"username": "",
5035+
"password": "",
5036+
"host": "",
5037+
"hostname": "",
5038+
"port": "",
5039+
"pathname": "//",
5040+
"search": "",
5041+
"hash": ""
5042+
},
5043+
{
5044+
"input": "////x/",
5045+
"base": "sc://x/",
5046+
"href": "sc:////x/",
5047+
"protocol": "sc:",
5048+
"username": "",
5049+
"password": "",
5050+
"host": "",
5051+
"hostname": "",
5052+
"port": "",
5053+
"pathname": "//x/",
5054+
"search": "",
5055+
"hash": ""
49105056
}
49115057
]

0 commit comments

Comments
 (0)