File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,9 @@ export function validateConfiguration(config: SQLiteCloudConfig): SQLiteCloudCon
200200 if ( ! config . connectionString ) {
201201 // build connection string from configuration, values are already validated
202202 // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
203- config . connectionString = `sqlitecloud://${ config . username } :${ config . password } @${ config . host } :${ config . port } /${ config . database } `
203+ config . connectionString = `sqlitecloud://${ encodeURIComponent ( config . username ) } :${ encodeURIComponent ( config . password ) } @${ config . host } :${ config . port } /${
204+ config . database
205+ } `
204206 }
205207
206208 return config
@@ -223,8 +225,8 @@ export function parseConnectionString(connectionString: string): SQLiteCloudConf
223225 } )
224226
225227 const config : SQLiteCloudConfig = {
226- username : url . username ,
227- password : url . password ,
228+ username : decodeURIComponent ( url . username ) ,
229+ password : decodeURIComponent ( url . password ) ,
228230 host : url . hostname ,
229231 port : url . port ? parseInt ( url . port ) : undefined ,
230232 ...options
Original file line number Diff line number Diff line change @@ -165,4 +165,17 @@ describe('parseConnectionString', () => {
165165 database : 'database'
166166 } )
167167 } )
168+
169+ it ( 'should handle url encoded password' , ( ) => {
170+ const connectionString = 'sqlitecloud://user:pass%25word@host:1234/database'
171+ const config = parseConnectionString ( connectionString )
172+
173+ expect ( config ) . toEqual ( {
174+ username : 'user' ,
175+ password : 'pass%word' ,
176+ host : 'host' ,
177+ port : 1234 ,
178+ database : 'database'
179+ } )
180+ } )
168181} )
You can’t perform that action at this time.
0 commit comments