@@ -7,16 +7,16 @@ if (!common.hasIntl)
7
7
const assert = require ( 'assert' ) ;
8
8
const url = require ( 'url' ) ;
9
9
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' ) ;
11
11
12
12
assert . strictEqual (
13
13
url . format ( myURL ) ,
14
- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
14
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
15
15
) ;
16
16
17
17
assert . strictEqual (
18
18
url . format ( myURL , { } ) ,
19
- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
19
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
20
20
) ;
21
21
22
22
{
@@ -36,82 +36,107 @@ assert.strictEqual(
36
36
// Any falsy value other than undefined will be treated as false.
37
37
// Any truthy value will be treated as true.
38
38
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
+
39
64
assert . strictEqual (
40
65
url . format ( myURL , { fragment : false } ) ,
41
- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b'
66
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b'
42
67
) ;
43
68
44
69
assert . strictEqual (
45
70
url . format ( myURL , { fragment : '' } ) ,
46
- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b'
71
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b'
47
72
) ;
48
73
49
74
assert . strictEqual (
50
75
url . format ( myURL , { fragment : 0 } ) ,
51
- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b'
76
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b'
52
77
) ;
53
78
54
79
assert . strictEqual (
55
80
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'
57
82
) ;
58
83
59
84
assert . strictEqual (
60
85
url . format ( myURL , { fragment : { } } ) ,
61
- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
86
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
62
87
) ;
63
88
64
89
assert . strictEqual (
65
90
url . format ( myURL , { search : false } ) ,
66
- 'http://xn--lck1c3crb1723bpq4a.com/a#c'
91
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a#c'
67
92
) ;
68
93
69
94
assert . strictEqual (
70
95
url . format ( myURL , { search : '' } ) ,
71
- 'http://xn--lck1c3crb1723bpq4a.com/a#c'
96
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a#c'
72
97
) ;
73
98
74
99
assert . strictEqual (
75
100
url . format ( myURL , { search : 0 } ) ,
76
- 'http://xn--lck1c3crb1723bpq4a.com/a#c'
101
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a#c'
77
102
) ;
78
103
79
104
assert . strictEqual (
80
105
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'
82
107
) ;
83
108
84
109
assert . strictEqual (
85
110
url . format ( myURL , { search : { } } ) ,
86
- 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
111
+ 'http://user:pass@ xn--lck1c3crb1723bpq4a.com/a?a=b#c'
87
112
) ;
88
113
89
114
assert . strictEqual (
90
115
url . format ( myURL , { unicode : true } ) ,
91
- 'http://理容ナカムラ.com/a?a=b#c'
116
+ 'http://user:pass@ 理容ナカムラ.com/a?a=b#c'
92
117
) ;
93
118
94
119
assert . strictEqual (
95
120
url . format ( myURL , { unicode : 1 } ) ,
96
- 'http://理容ナカムラ.com/a?a=b#c'
121
+ 'http://user:pass@ 理容ナカムラ.com/a?a=b#c'
97
122
) ;
98
123
99
124
assert . strictEqual (
100
125
url . format ( myURL , { unicode : { } } ) ,
101
- 'http://理容ナカムラ.com/a?a=b#c'
126
+ 'http://user:pass@ 理容ナカムラ.com/a?a=b#c'
102
127
) ;
103
128
104
129
assert . strictEqual (
105
130
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'
107
132
) ;
108
133
109
134
assert . strictEqual (
110
135
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'
112
137
) ;
113
138
114
139
assert . 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'
117
142
) ;
0 commit comments