File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -486,8 +486,18 @@ function parseUrl(url) {
486
486
host = host . slice ( host . indexOf ( '://' ) + 3 ) . split ( / [ ? / ] / ) [ 0 ]
487
487
host = decodeURIComponent ( host . slice ( host . indexOf ( '@' ) + 1 ) )
488
488
489
+ const urlObj = new URL ( url . replace ( host , host . split ( ',' ) [ 0 ] ) )
490
+
489
491
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
+ } ,
491
501
multihost : host . indexOf ( ',' ) > - 1 && host
492
502
}
493
503
}
Original file line number Diff line number Diff line change @@ -351,6 +351,11 @@ t('Connect using uri', async() =>
351
351
} ) ]
352
352
)
353
353
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
+
354
359
t ( 'Fail with proper error on no host' , async ( ) =>
355
360
[ 'ECONNREFUSED' , ( await new Promise ( ( resolve , reject ) => {
356
361
const sql = postgres ( 'postgres://localhost:33333/' + options . db , {
You can’t perform that action at this time.
0 commit comments