File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -486,8 +486,18 @@ function parseUrl(url) {
486486 host = host . slice ( host . indexOf ( '://' ) + 3 ) . split ( / [ ? / ] / ) [ 0 ]
487487 host = decodeURIComponent ( host . slice ( host . indexOf ( '@' ) + 1 ) )
488488
489+ const urlObj = new URL ( url . replace ( host , host . split ( ',' ) [ 0 ] ) )
490+
489491 return {
490- url : new URL ( url . replace ( host , host . split ( ',' ) [ 0 ] ) ) ,
492+ url : {
493+ username : decodeURIComponent ( urlObj . username ) ,
494+ password : decodeURIComponent ( urlObj . password ) ,
495+ host : urlObj . host ,
496+ hostname : urlObj . hostname ,
497+ port : urlObj . port ,
498+ pathname : urlObj . pathname ,
499+ searchParams : urlObj . searchParams
500+ } ,
491501 multihost : host . indexOf ( ',' ) > - 1 && host
492502 }
493503}
Original file line number Diff line number Diff line change @@ -351,6 +351,11 @@ t('Connect using uri', async() =>
351351 } ) ]
352352)
353353
354+ t ( 'Options from uri with special characters in user and pass' , async ( ) => {
355+ const opt = postgres ( { user : 'öla' , pass : 'pass^word' } ) . options
356+ return [ [ opt . user , opt . pass ] . toString ( ) , 'öla,pass^word' ]
357+ } )
358+
354359t ( 'Fail with proper error on no host' , async ( ) =>
355360 [ 'ECONNREFUSED' , ( await new Promise ( ( resolve , reject ) => {
356361 const sql = postgres ( 'postgres://localhost:33333/' + options . db , {
You can’t perform that action at this time.
0 commit comments