@@ -9,7 +9,7 @@ describe("url", () => {
9
9
loc . protocol = "https:" ;
10
10
loc . port = 4005 ;
11
11
loc . host = loc . hostname + ":" + loc . port ;
12
- const parsed = url ( undefined , loc ) ;
12
+ const parsed = url ( undefined , undefined , loc ) ;
13
13
expect ( parsed . host ) . to . be ( "woot.com" ) ;
14
14
expect ( parsed . protocol ) . to . be ( "https" ) ;
15
15
expect ( parsed . port ) . to . be ( "4005" ) ;
@@ -20,23 +20,23 @@ describe("url", () => {
20
20
loc . protocol = "https:" ;
21
21
loc . port = 3000 ;
22
22
loc . host = loc . hostname + ":" + loc . port ;
23
- const parsed = url ( "/test" , loc ) ;
23
+ const parsed = url ( "/test" , undefined , loc ) ;
24
24
expect ( parsed . host ) . to . be ( "woot.com" ) ;
25
25
expect ( parsed . protocol ) . to . be ( "https" ) ;
26
26
expect ( parsed . port ) . to . be ( "3000" ) ;
27
27
} ) ;
28
28
29
29
it ( "works with no protocol" , ( ) => {
30
30
loc . protocol = "http:" ;
31
- const parsed = url ( "localhost:3000" , loc ) ;
31
+ const parsed = url ( "localhost:3000" , undefined , loc ) ;
32
32
expect ( parsed . host ) . to . be ( "localhost" ) ;
33
33
expect ( parsed . port ) . to . be ( "3000" ) ;
34
34
expect ( parsed . protocol ) . to . be ( "http" ) ;
35
35
} ) ;
36
36
37
37
it ( "works with no schema" , ( ) => {
38
38
loc . protocol = "http:" ;
39
- const parsed = url ( "//localhost:3000" , loc ) ;
39
+ const parsed = url ( "//localhost:3000" , undefined , loc ) ;
40
40
expect ( parsed . host ) . to . be ( "localhost" ) ;
41
41
expect ( parsed . port ) . to . be ( "3000" ) ;
42
42
expect ( parsed . protocol ) . to . be ( "http" ) ;
@@ -46,16 +46,18 @@ describe("url", () => {
46
46
const id1 = url ( "http://google.com:80/" ) ;
47
47
const id2 = url ( "http://google.com/" ) ;
48
48
const id3 = url ( "https://google.com/" ) ;
49
+ const id4 = url ( "http://google.com/" , "/test" ) ;
49
50
expect ( id1 . id ) . to . be ( id2 . id ) ;
50
51
expect ( id1 . id ) . to . not . be ( id3 . id ) ;
51
52
expect ( id2 . id ) . to . not . be ( id3 . id ) ;
53
+ expect ( id2 . id ) . to . not . be ( id4 . id ) ;
52
54
} ) ;
53
55
54
56
it ( "identifies the namespace" , ( ) => {
55
57
loc . protocol = "http:" ;
56
58
loc . hostname = "woot.com" ;
57
59
58
- expect ( url ( "/woot" , loc ) . path ) . to . be ( "/woot" ) ;
60
+ expect ( url ( "/woot" , undefined , loc ) . path ) . to . be ( "/woot" ) ;
59
61
expect ( url ( "http://google.com" ) . path ) . to . be ( "/" ) ;
60
62
expect ( url ( "http://google.com/" ) . path ) . to . be ( "/" ) ;
61
63
} ) ;
@@ -74,10 +76,16 @@ describe("url", () => {
74
76
loc . port = "" ;
75
77
loc . host = loc . hostname + ":" + loc . port ;
76
78
77
- const parsed = url ( undefined , loc ) ;
79
+ const parsed = url ( undefined , undefined , loc ) ;
78
80
expect ( parsed . protocol ) . to . be ( "http" ) ;
79
81
expect ( parsed . host ) . to . be ( "::1" ) ;
80
82
expect ( parsed . port ) . to . be ( "80" ) ;
81
83
expect ( parsed . id ) . to . be ( "http://[::1]:80" ) ;
82
84
} ) ;
85
+
86
+ it ( "works with a custom path" , function ( ) {
87
+ const parsed = url ( "https://woot.com/some-namespace" , "/some-path" ) ;
88
+ expect ( parsed . id ) . to . be ( "https://woot.com:443/some-path" ) ;
89
+ expect ( parsed . path ) . to . be ( "/some-namespace" ) ;
90
+ } ) ;
83
91
} ) ;
0 commit comments