@@ -7,16 +7,16 @@ if (!common.hasIntl)
77const assert = require ( 'assert' ) ;
88const url = require ( 'url' ) ;
99
10- const myURL = new URL ( 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c' ) ;
10+ const myURL = new URL ( 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c' ) ;
1111
1212assert . strictEqual (
1313 url . format ( myURL ) ,
14- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
14+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
1515) ;
1616
1717assert . strictEqual (
1818 url . format ( myURL , { } ) ,
19- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
19+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
2020) ;
2121
2222{
@@ -36,82 +36,107 @@ assert.strictEqual(
3636// Any falsy value other than undefined will be treated as false.
3737// Any truthy value will be treated as true.
3838
39+ assert . strictEqual (
40+ url . format ( myURL , { auth : false } ) ,
41+ 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
42+ ) ;
43+
44+ assert . strictEqual (
45+ url . format ( myURL , { auth : '' } ) ,
46+ 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
47+ ) ;
48+
49+ assert . strictEqual (
50+ url . format ( myURL , { auth : 0 } ) ,
51+ 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
52+ ) ;
53+
54+ assert . strictEqual (
55+ url . format ( myURL , { auth : 1 } ) ,
56+ 'http://user:[email protected] /a?a=b#c' 57+ ) ;
58+
59+ assert . strictEqual (
60+ url . format ( myURL , { auth : { } } ) ,
61+ 'http://user:[email protected] /a?a=b#c' 62+ ) ;
63+
3964assert . strictEqual (
4065 url . format ( myURL , { fragment : false } ) ,
41- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b'
66+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b'
4267) ;
4368
4469assert . strictEqual (
4570 url . format ( myURL , { fragment : '' } ) ,
46- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b'
71+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b'
4772) ;
4873
4974assert . strictEqual (
5075 url . format ( myURL , { fragment : 0 } ) ,
51- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b'
76+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b'
5277) ;
5378
5479assert . strictEqual (
5580 url . format ( myURL , { fragment : 1 } ) ,
56- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
81+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
5782) ;
5883
5984assert . strictEqual (
6085 url . format ( myURL , { fragment : { } } ) ,
61- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
86+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
6287) ;
6388
6489assert . strictEqual (
6590 url . format ( myURL , { search : false } ) ,
66- 'http://xn--lck1c3crb1723bpq4a.com/a#c'
91+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a#c'
6792) ;
6893
6994assert . strictEqual (
7095 url . format ( myURL , { search : '' } ) ,
71- 'http://xn--lck1c3crb1723bpq4a.com/a#c'
96+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a#c'
7297) ;
7398
7499assert . strictEqual (
75100 url . format ( myURL , { search : 0 } ) ,
76- 'http://xn--lck1c3crb1723bpq4a.com/a#c'
101+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a#c'
77102) ;
78103
79104assert . strictEqual (
80105 url . format ( myURL , { search : 1 } ) ,
81- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
106+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
82107) ;
83108
84109assert . strictEqual (
85110 url . format ( myURL , { search : { } } ) ,
86- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
111+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
87112) ;
88113
89114assert . strictEqual (
90115 url . format ( myURL , { unicode : true } ) ,
91- 'http://理容ナカムラ.com/a?a=b#c'
116+ 'http://user:pass@ 理容ナカムラ.com/a?a=b#c'
92117) ;
93118
94119assert . strictEqual (
95120 url . format ( myURL , { unicode : 1 } ) ,
96- 'http://理容ナカムラ.com/a?a=b#c'
121+ 'http://user:pass@ 理容ナカムラ.com/a?a=b#c'
97122) ;
98123
99124assert . strictEqual (
100125 url . format ( myURL , { unicode : { } } ) ,
101- 'http://理容ナカムラ.com/a?a=b#c'
126+ 'http://user:pass@ 理容ナカムラ.com/a?a=b#c'
102127) ;
103128
104129assert . strictEqual (
105130 url . format ( myURL , { unicode : false } ) ,
106- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
131+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
107132) ;
108133
109134assert . strictEqual (
110135 url . format ( myURL , { unicode : 0 } ) ,
111- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
136+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
112137) ;
113138
114139assert . strictEqual (
115- url . format ( new URL ( 'http://xn--0zwm56d.com:8080/path' ) , { unicode : true } ) ,
116- 'http://测试.com:8080/path'
140+ url . format ( new URL ( 'http://user:pass@ xn--0zwm56d.com:8080/path' ) , { unicode : true } ) ,
141+ 'http://user:pass@ 测试.com:8080/path'
117142) ;
0 commit comments