@@ -88,7 +88,7 @@ suite('URI', () => {
8888 assert . equal ( uri2 . fragment , uri3 . fragment ) ;
8989 } ) ;
9090
91- test ( 'with, identity' , ( ) => {
91+ test ( 'URI# with, identity' , ( ) => {
9292 let uri = URI . parse ( 'foo:bar/path' ) ;
9393
9494 let uri2 = uri . with ( null ! ) ;
@@ -101,7 +101,7 @@ suite('URI', () => {
101101 assert . ok ( uri === uri2 ) ;
102102 } ) ;
103103
104- test ( 'with, changes' , ( ) => {
104+ test ( 'URI# with, changes' , ( ) => {
105105 assert . equal ( URI . parse ( 'before:some/file/path' ) . with ( { scheme : 'after' } ) . toString ( ) , 'after:some/file/path' ) ;
106106 assert . equal ( URI . from ( { scheme : 's' } ) . with ( { scheme : 'http' , path : '/api/files/test.me' , query : 't=1234' } ) . toString ( ) , 'http:/api/files/test.me?t=1234' ) ;
107107 assert . equal ( URI . from ( { scheme : 's' } ) . with ( { scheme : 'http' , authority : '' , path : '/api/files/test.me' , query : 't=1234' , fragment : '' } ) . toString ( ) , 'http:/api/files/test.me?t=1234' ) ;
@@ -111,7 +111,7 @@ suite('URI', () => {
111111 assert . equal ( URI . from ( { scheme : 's' } ) . with ( { scheme : 'boo' , authority : '' , path : '/api/files/test.me' , query : 't=1234' , fragment : '' } ) . toString ( ) , 'boo:/api/files/test.me?t=1234' ) ;
112112 } ) ;
113113
114- test ( 'with, remove components #8465' , ( ) => {
114+ test ( 'URI# with, remove components #8465' , ( ) => {
115115 assert . equal ( URI . parse ( 'scheme://authority/path' ) . with ( { authority : '' } ) . toString ( ) , 'scheme:/path' ) ;
116116 assert . equal ( URI . parse ( 'scheme:/path' ) . with ( { authority : 'authority' } ) . with ( { authority : '' } ) . toString ( ) , 'scheme:/path' ) ;
117117 assert . equal ( URI . parse ( 'scheme:/path' ) . with ( { authority : 'authority' } ) . with ( { authority : null } ) . toString ( ) , 'scheme:/path' ) ;
@@ -121,7 +121,7 @@ suite('URI', () => {
121121 assert . equal ( URI . parse ( 'scheme:/path' ) . with ( { authority : null } ) . toString ( ) , 'scheme:/path' ) ;
122122 } ) ;
123123
124- test ( 'with, validation' , ( ) => {
124+ test ( 'URI# with, validation' , ( ) => {
125125 let uri = URI . parse ( 'foo:bar/path' ) ;
126126 assert . throws ( ( ) => uri . with ( { scheme : 'fai:l' } ) ) ;
127127 assert . throws ( ( ) => uri . with ( { scheme : 'fäil' } ) ) ;
@@ -310,50 +310,52 @@ suite('URI', () => {
310310 assert . equal ( value . toString ( ) , 'file:///a.file' ) ;
311311 } ) ;
312312
313+
314+ function assertToString ( input : string | URI , expected : string ) {
315+ if ( typeof input === 'string' ) {
316+ input = URI . parse ( input ) ;
317+ }
318+ const actual = input . toString ( ) ;
319+ assert . equal ( actual , expected . toString ( ) ) ;
320+ }
321+
313322 test ( 'URI.toString, only scheme and query' , ( ) => {
314- const value = URI . parse ( 'stuff:?qüery' ) ;
315- assert . equal ( value . toString ( ) , 'stuff:?q%C3%BCery' ) ;
323+ assertToString ( 'stuff:?qüery' , 'stuff:?q%C3%BCery' ) ;
316324 } ) ;
317325
318326 test ( 'URI#toString, upper-case percent espaces' , ( ) => {
319- const value = URI . parse ( 'file://sh%c3%a4res/path' ) ;
320- assert . equal ( value . toString ( ) , 'file://sh%C3%A4res/path' ) ;
327+ assertToString ( 'file://sh%c3%a4res/path' , 'file://sh%C3%A4res/path' ) ;
328+ assertToString ( 'file://sh%c3%z4res/path' , 'file://sh%C3%z4res/path' ) ;
329+ assertToString ( 'file:///sh%a0res/path' , 'file:///sh%A0res/path' ) ; // also upper-cased invalid sequence
321330 } ) ;
322331
323332 test ( 'URI#toString, lower-case windows drive letter' , ( ) => {
324- assert . equal ( URI . parse ( 'untitled:c:/Users/jrieken/Code/abc.txt' ) . toString ( ) , 'untitled:c%3A/Users/jrieken/Code/abc.txt' ) ;
325- assert . equal ( URI . parse ( 'untitled:C:/Users/jrieken/Code/abc.txt' ) . toString ( ) , 'untitled:c%3A/Users/jrieken/Code/abc.txt' ) ;
333+ assertToString ( 'untitled:c:/Users/jrieken/Code/abc.txt' , 'untitled:c%3A/Users/jrieken/Code/abc.txt' ) ;
334+ assertToString ( 'untitled:C:/Users/jrieken/Code/abc.txt' , 'untitled:c%3A/Users/jrieken/Code/abc.txt' ) ;
326335 } ) ;
327336
328337 test ( 'URI#toString, escape all the bits' , ( ) => {
329-
330338 const value = URI . file ( '/Users/jrieken/Code/_samples/18500/Mödel + Other Thîngß/model.js' ) ;
331- assert . equal ( value . toString ( ) , 'file:///Users/jrieken/Code/_samples/18500/M%C3%B6del%20+%20Other%20Th%C3%AEng%C3%9F/model.js' ) ;
339+ assertToString ( value , 'file:///Users/jrieken/Code/_samples/18500/M%C3%B6del%20+%20Other%20Th%C3%AEng%C3%9F/model.js' ) ;
332340 } ) ;
333341
334342 test ( 'URI#toString, don\'t encode port' , ( ) => {
335343 let value = URI . parse ( 'http://localhost:8080/far' ) ;
336- assert . equal ( value . toString ( ) , 'http://localhost:8080/far' ) ;
344+ assertToString ( value , 'http://localhost:8080/far' ) ;
337345
338346 value = URI . from ( { scheme : 'http' , authority : 'löcalhost:8080' , path : '/far' , query : undefined , fragment : undefined } ) ;
339- assert . equal ( value . toString ( ) , 'http://l%C3%B6calhost:8080/far' ) ;
347+ assertToString ( value , 'http://l%C3%B6calhost:8080/far' ) ;
340348 } ) ;
341349
342350 test ( 'URI#toString, user information in authority' , ( ) => {
343- let value = URI . parse ( 'http://foo:bar@localhost/far' ) ;
344- assert . equal ( value . toString ( ) , 'http://foo:bar@localhost/far' ) ;
345-
346- value = URI . parse ( 'http://foo@localhost/far' ) ;
347- assert . equal ( value . toString ( ) , 'http://foo@localhost/far' ) ;
348-
349- value = URI . parse ( 'http://foo:bAr@localhost:8080/far' ) ;
350- assert . equal ( value . toString ( ) , 'http://foo:bAr@localhost:8080/far' ) ;
351-
352- value = URI . parse ( 'http://foo@localhost:8080/far' ) ;
353- assert . equal ( value . toString ( ) , 'http://foo@localhost:8080/far' ) ;
354-
355- value = URI . from ( { scheme : 'http' , authority : 'föö:bör@löcalhost:8080' , path : '/far' , query : undefined , fragment : undefined } ) ;
356- assert . equal ( value . toString ( ) , 'http://f%C3%B6%C3%B6:b%C3%B6r@l%C3%B6calhost:8080/far' ) ;
351+ assertToString ( 'http://foo:bar@localhost/far' , 'http://foo:bar@localhost/far' ) ;
352+ assertToString ( 'http://foo@localhost/far' , 'http://foo@localhost/far' ) ;
353+ assertToString ( 'http://foo:bAr@localhost:8080/far' , 'http://foo:bAr@localhost:8080/far' ) ;
354+ assertToString ( 'http://foo@localhost:8080/far' , 'http://foo@localhost:8080/far' ) ;
355+ assertToString (
356+ URI . from ( { scheme : 'http' , authority : 'föö:bör@löcalhost:8080' , path : '/far' , query : undefined , fragment : undefined } ) ,
357+ 'http://f%C3%B6%C3%B6:b%C3%B6r@l%C3%B6calhost:8080/far'
358+ ) ;
357359 } ) ;
358360
359361 test ( 'correctFileUriToFilePath2' , ( ) => {
0 commit comments