mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
feat(pg-connection-string): throw correct error when URL parsing fails
Fixes #3513
This commit is contained in:
parent
27a2754787
commit
1b2bedc9c8
@ -35,6 +35,7 @@ function parse(str, options = {}) {
|
||||
} catch (err) {
|
||||
// Remove the input from the error message to avoid leaking sensitive information
|
||||
err.input && (err.input = '*****REDACTED*****')
|
||||
throw err
|
||||
}
|
||||
|
||||
// We'd like to use Object.fromEntries() here but Node.js 10 does not support it
|
||||
|
||||
@ -330,6 +330,7 @@ describe('parse', function () {
|
||||
parse(connectionString)
|
||||
} catch (err: unknown) {
|
||||
expect(JSON.stringify(err)).to.not.include(password, 'Password should not be in the error message')
|
||||
expect(JSON.stringify(err)).to.include('REDACTED', 'The thrown error should contain the redacted URL')
|
||||
return
|
||||
}
|
||||
throw new Error('Expected an error to be thrown')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user