@@ -70,6 +70,8 @@ const resolveWithTestChecks = function(urlStr, baseStr = undefined) {
7070 assertEquals ( nativeResolve . pathname , packageResolve . pathname ) ;
7171 assertEquals ( nativeResolve . search , packageResolve . search ) ;
7272 assertEquals ( nativeResolve . hash , packageResolve . hash ) ;
73+ assertEquals ( nativeResolve . href , packageResolve . href ) ;
74+ assertEquals ( nativeResolve . toString ( ) , packageResolve . toString ( ) ) ;
7375 }
7476 if ( packageThrow ) {
7577 throw packageThrow ;
@@ -92,6 +94,8 @@ testSuite({
9294 assertEquals ( '/' , url . pathname ) ;
9395 assertEquals ( '' , url . search ) ;
9496 assertEquals ( '' , url . hash ) ;
97+ assertEquals ( 'http://www.google.com/' , url . toString ( ) ) ;
98+ assertEquals ( 'http://www.google.com/' , url . href ) ;
9599 } ,
96100
97101 testWithPort ( ) {
@@ -106,6 +110,8 @@ testSuite({
106110 assertEquals ( '/' , url . pathname ) ;
107111 assertEquals ( '' , url . search ) ;
108112 assertEquals ( '' , url . hash ) ;
113+ assertEquals ( 'http://www.google.com:8080/' , url . toString ( ) ) ;
114+ assertEquals ( 'http://www.google.com:8080/' , url . href ) ;
109115 } ,
110116
111117 testWithPath ( ) {
@@ -120,6 +126,8 @@ testSuite({
120126 assertEquals ( '/search' , url . pathname ) ;
121127 assertEquals ( '' , url . search ) ;
122128 assertEquals ( '' , url . hash ) ;
129+ assertEquals ( 'http://www.google.com/search' , url . toString ( ) ) ;
130+ assertEquals ( 'http://www.google.com/search' , url . href ) ;
123131 } ,
124132
125133 testWithQueryData ( ) {
@@ -134,6 +142,8 @@ testSuite({
134142 assertEquals ( '/path' , url . pathname ) ;
135143 assertEquals ( '?a=b&b=c' , url . search ) ;
136144 assertEquals ( '' , url . hash ) ;
145+ assertEquals ( 'http://www.google.com/path?a=b&b=c' , url . toString ( ) ) ;
146+ assertEquals ( 'http://www.google.com/path?a=b&b=c' , url . href ) ;
137147 } ,
138148
139149 testComplex ( ) {
@@ -149,6 +159,10 @@ testSuite({
149159 assertEquals ( '/path' , url . pathname ) ;
150160 assertEquals ( '?q=query' , url . search ) ;
151161 assertEquals ( '#fragmento' , url . hash ) ;
162+ assertEquals (
163+ 'http://www.google.com:8080/path?q=query#fragmento' , url . toString ( ) ) ;
164+ assertEquals (
165+ 'http://www.google.com:8080/path?q=query#fragmento' , url . href ) ;
152166 } ,
153167
154168 testWithNewline ( ) {
@@ -162,6 +176,10 @@ testSuite({
162176 assertEquals ( '/path' , url . pathname ) ;
163177 assertEquals ( '?q=query' , url . search ) ;
164178 assertEquals ( '#fragmento' , url . hash ) ;
179+ assertEquals (
180+ 'http://www.google.com:8080/path?q=query#fragmento' , url . toString ( ) ) ;
181+ assertEquals (
182+ 'http://www.google.com:8080/path?q=query#fragmento' , url . href ) ;
165183 } ,
166184
167185 testWithRelativeParam ( ) {
@@ -175,6 +193,10 @@ testSuite({
175193 assertEquals ( '/path' , url . pathname ) ;
176194 assertEquals ( '?q=query' , url . search ) ;
177195 assertEquals ( '#fragmento' , url . hash ) ;
196+ assertEquals (
197+ 'http://www.google.com:8080/path?q=query#fragmento' , url . toString ( ) ) ;
198+ assertEquals (
199+ 'http://www.google.com:8080/path?q=query#fragmento' , url . href ) ;
178200 } ,
179201
180202 testWithRelativeParamThatIsAbsolute ( ) {
@@ -192,6 +214,9 @@ testSuite({
192214 assertEquals ( '/path' , url . pathname ) ;
193215 assertEquals ( '?q=query' , url . search ) ;
194216 assertEquals ( '#fragmento' , url . hash ) ;
217+ assertEquals (
218+ 'https://docs.google.com/path?q=query#fragmento' , url . toString ( ) ) ;
219+ assertEquals ( 'https://docs.google.com/path?q=query#fragmento' , url . href ) ;
195220 } ,
196221
197222 testWithBaseThatHasRelativeParts ( ) {
@@ -206,6 +231,9 @@ testSuite({
206231 assertEquals ( '/path1' , url . pathname ) ;
207232 assertEquals ( '?q=query' , url . search ) ;
208233 assertEquals ( '#fragmento' , url . hash ) ;
234+ assertEquals (
235+ 'https://docs.google.com/path1?q=query#fragmento' , url . toString ( ) ) ;
236+ assertEquals ( 'https://docs.google.com/path1?q=query#fragmento' , url . href ) ;
209237 } ,
210238
211239 testWithBaseThatHasRelativePartsAndOnlySearchRelative ( ) {
@@ -220,6 +248,8 @@ testSuite({
220248 assertEquals ( '/path' , url . pathname ) ;
221249 assertEquals ( '?q=query' , url . search ) ;
222250 assertEquals ( '' , url . hash ) ;
251+ assertEquals ( 'https://google.com/path?q=query' , url . toString ( ) ) ;
252+ assertEquals ( 'https://google.com/path?q=query' , url . href ) ;
223253 } ,
224254
225255 testWithBaseThatHasRelativePartsAndOnlyHashRelative ( ) {
@@ -235,6 +265,8 @@ testSuite({
235265 // And so is the query
236266 assertEquals ( '?query=q' , url . search ) ;
237267 assertEquals ( '#query' , url . hash ) ;
268+ assertEquals ( 'https://google.com/path?query=q#query' , url . toString ( ) ) ;
269+ assertEquals ( 'https://google.com/path?query=q#query' , url . href ) ;
238270 } ,
239271
240272 testWithBaseAndNoIndicatorsInRelative ( ) {
@@ -249,6 +281,8 @@ testSuite({
249281 assertEquals ( '/query' , url . pathname ) ;
250282 assertEquals ( '' , url . search ) ;
251283 assertEquals ( '' , url . hash ) ;
284+ assertEquals ( 'https://google.com/query' , url . toString ( ) ) ;
285+ assertEquals ( 'https://google.com/query' , url . href ) ;
252286 } ,
253287
254288 testResolvesRelativeToRelativePath ( ) {
@@ -262,6 +296,8 @@ testSuite({
262296 assertEquals ( '/new' , url . pathname ) ;
263297 assertEquals ( '?q=query' , url . search ) ;
264298 assertEquals ( '' , url . hash ) ;
299+ assertEquals ( 'https://google.com/new?q=query' , url . toString ( ) ) ;
300+ assertEquals ( 'https://google.com/new?q=query' , url . href ) ;
265301 } ,
266302
267303 testResolvesRelativeToRelativePathBackslash ( ) {
@@ -275,6 +311,8 @@ testSuite({
275311 assertEquals ( '/new' , url . pathname ) ;
276312 assertEquals ( '?q=query' , url . search ) ;
277313 assertEquals ( '' , url . hash ) ;
314+ assertEquals ( 'https://google.com/new?q=query' , url . toString ( ) ) ;
315+ assertEquals ( 'https://google.com/new?q=query' , url . href ) ;
278316 } ,
279317
280318 testResolvesTwoDots ( ) {
@@ -289,6 +327,8 @@ testSuite({
289327 // "after" that to be removed - search and hash
290328 assertEquals ( url . search , '' ) ;
291329 assertEquals ( url . hash , '' ) ;
330+ assertEquals ( 'https://google.com/maps/' , url . toString ( ) ) ;
331+ assertEquals ( 'https://google.com/maps/' , url . href ) ;
292332 } ,
293333
294334 testResolvesTwoDotsNoBasePath ( ) {
@@ -302,6 +342,8 @@ testSuite({
302342 // "after" that to be removed - search and hash
303343 assertEquals ( url . search , '' ) ;
304344 assertEquals ( url . hash , '' ) ;
345+ assertEquals ( 'https://google.com/' , url . toString ( ) ) ;
346+ assertEquals ( 'https://google.com/' , url . href ) ;
305347 } ,
306348
307349 testResolvesTwoDotsShortBasePath ( ) {
@@ -316,6 +358,7 @@ testSuite({
316358 // "after" that to be removed - search and hash
317359 assertEquals ( url . search , '' ) ;
318360 assertEquals ( url . hash , '' ) ;
361+ assertEquals ( 'https://google.com/' , url . toString ( ) ) ;
319362 } ,
320363
321364 testResolvesDot ( ) {
@@ -329,6 +372,8 @@ testSuite({
329372 // "after" that to be removed - search and hash
330373 assertEquals ( url . search , '' ) ;
331374 assertEquals ( url . hash , '' ) ;
375+ assertEquals ( 'https://google.com/maps/search/' , url . toString ( ) ) ;
376+ assertEquals ( 'https://google.com/maps/search/' , url . href ) ;
332377 } ,
333378
334379 testResolvesDotNoBasePath ( ) {
@@ -341,6 +386,8 @@ testSuite({
341386 // "after" that to be removed - search and hash
342387 assertEquals ( url . search , '' ) ;
343388 assertEquals ( url . hash , '' ) ;
389+ assertEquals ( 'https://google.com/' , url . toString ( ) ) ;
390+ assertEquals ( 'https://google.com/' , url . href ) ;
344391 } ,
345392
346393 testResolvesDotShortBasePath ( ) {
@@ -354,6 +401,8 @@ testSuite({
354401 // "after" that to be removed - search and hash
355402 assertEquals ( url . search , '' ) ;
356403 assertEquals ( url . hash , '' ) ;
404+ assertEquals ( 'https://google.com/' , url . toString ( ) ) ;
405+ assertEquals ( 'https://google.com/' , url . href ) ;
357406 } ,
358407
359408 testResolvesEmptyString ( ) {
@@ -365,11 +414,16 @@ testSuite({
365414 if ( ! userAgent . isEdge ( ) ) {
366415 assertEquals ( url . pathname , '/maps/search/new' ) ;
367416 assertEquals ( url . search , '?hl=de' ) ;
417+ assertEquals (
418+ 'https://google.com/maps/search/new?hl=de' , url . toString ( ) ) ;
419+ assertEquals ( 'https://google.com/maps/search/new?hl=de' , url . href ) ;
368420 } else {
369421 // Edge is weird here and instead follows the same conventions for '.'
370422 // it removes one chunk of path and every part after it.
371423 assertEquals ( url . pathname , '/maps/search/' ) ;
372424 assertEquals ( url . search , '' ) ;
425+ assertEquals ( 'https://google.com/maps/search/' , url . toString ( ) ) ;
426+ assertEquals ( 'https://google.com/maps/search/' , url . href ) ;
373427 }
374428 assertEquals ( url . hash , '' ) ;
375429 } ,
0 commit comments