feat(pg-connection-string): throw correct error when URL parsing fails

Fixes #3513
This commit is contained in:
Mathias Bockwoldt 2025-07-28 12:48:29 +00:00 committed by GitHub
parent 27a2754787
commit 1b2bedc9c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -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

View File

@ -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')