@@ -12,7 +12,6 @@ test('main', t => {
12
12
t . is ( normalizeUrl ( 'http://sindresorhus.com' ) , 'http://sindresorhus.com' ) ;
13
13
t . is ( normalizeUrl ( 'http://sindresorhus.com:80' ) , 'http://sindresorhus.com' ) ;
14
14
t . is ( normalizeUrl ( 'https://sindresorhus.com:443' ) , 'https://sindresorhus.com' ) ;
15
- t . is ( normalizeUrl ( 'ftp://sindresorhus.com:21' ) , 'ftp://sindresorhus.com' ) ;
16
15
t . is ( normalizeUrl ( 'http://www.sindresorhus.com' ) , 'http://sindresorhus.com' ) ;
17
16
t . is ( normalizeUrl ( 'www.com' ) , 'http://www.com' ) ;
18
17
t . is ( normalizeUrl ( 'http://www.www.sindresorhus.com' ) , 'http://www.www.sindresorhus.com' ) ;
@@ -37,27 +36,25 @@ test('main', t => {
37
36
t . is ( normalizeUrl ( 'http://sindresorhus.com/foo#bar:~:text=hello%20world' , { stripHash : true } ) , 'http://sindresorhus.com/foo' ) ;
38
37
t . is ( normalizeUrl ( 'http://sindresorhus.com/foo/bar/../baz' ) , 'http://sindresorhus.com/foo/baz' ) ;
39
38
t . is ( normalizeUrl ( 'http://sindresorhus.com/foo/bar/./baz' ) , 'http://sindresorhus.com/foo/bar/baz' ) ;
40
- t . is ( normalizeUrl ( 'sindre://www.sorhus.com' ) , 'sindre://sorhus.com' ) ;
41
- t . is ( normalizeUrl ( 'sindre://www.sorhus.com/' ) , 'sindre://sorhus.com' ) ;
42
- t . is ( normalizeUrl ( 'sindre://www.sorhus.com/foo/bar' ) , 'sindre://sorhus.com/foo/bar' ) ;
39
+ // t.is(normalizeUrl('sindre://www.sorhus.com'), 'sindre://sorhus.com');
40
+ // t.is(normalizeUrl('sindre://www.sorhus.com/'), 'sindre://sorhus.com');
41
+ // t.is(normalizeUrl('sindre://www.sorhus.com/foo/bar'), 'sindre://sorhus.com/foo/bar');
43
42
t . is ( normalizeUrl ( 'https://i.vimeocdn.com/filter/overlay?src0=https://i.vimeocdn.com/video/598160082_1280x720.jpg&src1=https://f.vimeocdn.com/images_v6/share/play_icon_overlay.png' ) , 'https://i.vimeocdn.com/filter/overlay?src0=https://i.vimeocdn.com/video/598160082_1280x720.jpg&src1=https://f.vimeocdn.com/images_v6/share/play_icon_overlay.png' ) ;
44
43
} ) ;
45
44
46
45
test ( 'stripAuthentication option' , t => {
47
46
t . is ( normalizeUrl ( 'http://user:password@www.sindresorhus.com' ) , 'http://sindresorhus.com' ) ;
48
47
t . is ( normalizeUrl ( 'https://user:password@www.sindresorhus.com' ) , 'https://sindresorhus.com' ) ;
49
48
t . is ( normalizeUrl ( 'https://user:password@www.sindresorhus.com/@user' ) , 'https://sindresorhus.com/@user' ) ;
50
- t . is ( normalizeUrl ( 'user:password@sindresorhus.com' ) , 'http://sindresorhus.com' ) ;
51
49
t . is ( normalizeUrl ( 'http://user:password@www.êxample.com' ) , 'http://xn--xample-hva.com' ) ;
52
- t . is ( normalizeUrl ( 'sindre://user:password@www.sorhus.com' ) , 'sindre://sorhus.com' ) ;
50
+ // t.is(normalizeUrl('sindre://user:password@www.sorhus.com'), 'sindre://sorhus.com');
53
51
54
52
const options = { stripAuthentication : false } ;
55
53
t . is ( normalizeUrl ( 'http://user:password@www.sindresorhus.com' , options ) , 'http://user:password@sindresorhus.com' ) ;
56
54
t . is ( normalizeUrl ( 'https://user:password@www.sindresorhus.com' , options ) , 'https://user:password@sindresorhus.com' ) ;
57
55
t . is ( normalizeUrl ( 'https://user:password@www.sindresorhus.com/@user' , options ) , 'https://user:password@sindresorhus.com/@user' ) ;
58
- t . is ( normalizeUrl ( 'user:password@sindresorhus.com' , options ) , 'http://user:password@sindresorhus.com' ) ;
59
56
t . is ( normalizeUrl ( 'http://user:password@www.êxample.com' , options ) , 'http://user:password@xn--xample-hva.com' ) ;
60
- t . is ( normalizeUrl ( 'sindre://user:password@www.sorhus.com' , options ) , 'sindre://user:password@sorhus.com' ) ;
57
+ // t.is(normalizeUrl('sindre://user:password@www.sorhus.com', options), 'sindre://user:password@sorhus.com');
61
58
} ) ;
62
59
63
60
test ( 'stripProtocol option' , t => {
@@ -66,8 +63,6 @@ test('stripProtocol option', t => {
66
63
t . is ( normalizeUrl ( 'http://sindresorhus.com' , options ) , 'sindresorhus.com' ) ;
67
64
t . is ( normalizeUrl ( 'https://www.sindresorhus.com' , options ) , 'sindresorhus.com' ) ;
68
65
t . is ( normalizeUrl ( '//www.sindresorhus.com' , options ) , 'sindresorhus.com' ) ;
69
- t . is ( normalizeUrl ( 'sindre://user:password@www.sorhus.com' , options ) , 'sindre://sorhus.com' ) ;
70
- t . is ( normalizeUrl ( 'sindre://www.sorhus.com' , options ) , 'sindre://sorhus.com' ) ;
71
66
} ) ;
72
67
73
68
test ( 'stripTextFragment option' , t => {
@@ -98,7 +93,7 @@ test('stripWWW option', t => {
98
93
t . is ( normalizeUrl ( 'http://www.sindresorhus.com' , options ) , 'http://www.sindresorhus.com' ) ;
99
94
t . is ( normalizeUrl ( 'www.sindresorhus.com' , options ) , 'http://www.sindresorhus.com' ) ;
100
95
t . is ( normalizeUrl ( 'http://www.êxample.com' , options ) , 'http://www.xn--xample-hva.com' ) ;
101
- t . is ( normalizeUrl ( 'sindre://www.sorhus.com' , options ) , 'sindre://www.sorhus.com' ) ;
96
+ // t.is(normalizeUrl('sindre://www.sorhus.com', options), 'sindre://www.sorhus.com');
102
97
103
98
const options2 = { stripWWW : true } ;
104
99
t . is ( normalizeUrl ( 'http://www.vue.amsterdam' , options2 ) , 'http://vue.amsterdam' ) ;
@@ -393,14 +388,6 @@ test('prevents homograph attack', t => {
393
388
t . is ( normalizeUrl ( 'https://ebаy.com' ) , 'https://xn--eby-7cd.com' ) ;
394
389
} ) ;
395
390
396
- test ( 'view-source URL' , t => {
397
- t . throws ( ( ) => {
398
- normalizeUrl ( 'view-source:https://www.sindresorhus.com' ) ;
399
- } , {
400
- message : '`view-source:` is not supported as it is a non-standard protocol' ,
401
- } ) ;
402
- } ) ;
403
-
404
391
test ( 'does not have exponential performance for data URLs' , t => {
405
392
for ( let index = 0 ; index < 1000 ; index += 50 ) {
406
393
const url = 'data:' + Array . from ( { length : index } ) . fill ( ',#' ) . join ( '' ) + '\ra' ;
@@ -414,3 +401,9 @@ test('does not have exponential performance for data URLs', t => {
414
401
t . true ( difference < 100 , `Execution time: ${ difference } ` ) ;
415
402
}
416
403
} ) ;
404
+
405
+ test ( 'ignore custom schemes' , t => {
406
+ t . is ( normalizeUrl ( 'tel:004346382763' ) , 'tel:004346382763' ) ;
407
+ t . is ( normalizeUrl ( 'mailto:office@foo.com' ) , 'mailto:office@foo.com' ) ;
408
+ t . is ( normalizeUrl ( 'sindre://www.sindresorhus.com' ) , 'sindre://www.sindresorhus.com' ) ;
409
+ } ) ;
0 commit comments